本文整理汇总了Python中javax.swing.JButton.actionPerformed方法的典型用法代码示例。如果您正苦于以下问题:Python JButton.actionPerformed方法的具体用法?Python JButton.actionPerformed怎么用?Python JButton.actionPerformed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.actionPerformed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import actionPerformed [as 别名]
def __init__(self):
self.setLayout(GridBagLayout())
shrinkX = JButton("shrinkX")
shrinkX.actionPerformed = lambda event : rescaleLayout(0.5, 1)
constr = GridBagConstraints()
constr.gridx = 0
constr.gridy = 0
self.add(shrinkX, constr)
growX = JButton("growX")
growX.actionPerformed = lambda event : rescaleLayout(1.5, 1)
constr = GridBagConstraints()
constr.gridx = 2
constr.gridy = 0
self.add(growX, constr)
shrinkY = JButton("shrinkY")
shrinkY.actionPerformed = lambda event : rescaleLayout(1, 0.5)
constr = GridBagConstraints()
constr.gridx = 0
constr.gridy = 2
self.add(shrinkY, constr)
growY = JButton("growY")
growY.actionPerformed = lambda event : rescaleLayout(1, 1.5)
constr = GridBagConstraints()
constr.gridx = 2
constr.gridy = 2
self.add(growY, constr)
centerB = JButton("center")
centerB.actionPerformed = lambda event : center()
constr = GridBagConstraints()
constr.gridx = 1
constr.gridy = 1
self.add(centerB, constr)
ui.dock(self)
示例2: create_file_choice_button
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import actionPerformed [as 别名]
def create_file_choice_button(name, label_text):
button = JButton('Click to select')
label = JLabel(label_text)
file_chooser = JFileChooser()
def choose_file(event):
user_did_choose_file = (file_chooser.showOpenDialog(frame) ==
JFileChooser.APPROVE_OPTION)
if user_did_choose_file:
file_ = file_chooser.getSelectedFile();
button.text = chosen_values[name] = str(file_)
button.actionPerformed = choose_file
panel.add(label)
panel.add(button)