python JButton Jython示例!!!!

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python JButton Jython示例!!!!相关的知识,希望对你有一定的参考价值。


from javax.swing import *
from java.awt import BorderLayout

class Example:
    def setText(self, event):
        self.label.text = 'Button Clicked!!'

    def __init__(self):
        frame = JFrame('Jython JButton Example!!')
        frame.setSize(300, 100)
        frame.setLayout(BorderLayout())
        self.label = JLabel('Hello!! from Jython :D')
        frame.add(self.label, BorderLayout.NORTH)
        button = JButton('Click Me', actionPerformed = self.setText)
        frame.add(button, BorderLayout.SOUTH)
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
        frame.setVisible(True)

if __name__ == '__main__':
    Example()

以上是关于python JButton Jython示例!!!!的主要内容,如果未能解决你的问题,请参考以下文章