本文整理汇总了Python中javax.swing.JButton.addActionListener方法的典型用法代码示例。如果您正苦于以下问题:Python JButton.addActionListener方法的具体用法?Python JButton.addActionListener怎么用?Python JButton.addActionListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.addActionListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tree
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def tree():
"""
tree(xmlfile="dsm2.xml")
creates a tree view on a given xml file of dsm2 input data
"""
tv = TreeViewer()
mp2 = JPanel()
mp2.setLayout(BorderLayout())
tf = JTextField("dsm2.inp")
pb = JButton("parse")
mp2.add(tf,BorderLayout.CENTER)
mp2.add(pb,BorderLayout.EAST)
class ParseListener(ActionListener):
def __init__(self,tf,tv,fr):
self.tf = tf
self.tv = tv
self.fr = fr
def actionPerformed(self,evt):
dsm2file = self.tf.getText()
parser = DSM2Parser(dsm2file)
self.tv.xdoc = parser.dsm2_data.toXml()
self.fr.getContentPane().add(self.tv.gui(),BorderLayout.CENTER)
self.fr.pack()
self.fr.setVisible(1)
fr = JFrame()
fr.setTitle("DSM2Tree")
fr.setLocation(100,100)
fr.setSize(600,60)
fr.getContentPane().setLayout(BorderLayout())
fr.getContentPane().add(mp2,BorderLayout.NORTH)
al = ParseListener(tf,tv,fr)
pb.addActionListener(al)
fr.pack()
fr.setVisible(1)
示例2: __init__
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def __init__(self, frame, chart, pingFun):
JDialog(frame)
self.setTitle("Chart Settings")
self.setModal(True)
self.pingFun = pingFun
pane = self.getRootPane().getContentPane()
pane.setLayout(GridLayout(7, 2))
pane.add(JLabel("Marker color"))
self.markerPanel = self.createColorPanel(chart.markerColor, pane)
pane.add(JLabel("Positive selection color"))
self.posPanel = self.createColorPanel(chart.posColor, pane)
pane.add(JLabel("Neutral color"))
self.neuPanel = self.createColorPanel(chart.neuColor, pane)
pane.add(JLabel("Balancing selection color "))
self.balPanel = self.createColorPanel(chart.balColor, pane)
self.add(JLabel("Label candidate selected loci"))
self.selLabel = JCheckBox()
self.selLabel.setSelected(chart.labelSelected)
self.add(self.selLabel)
self.add(JLabel("Label candidate neutral loci"))
self.neuLabel = JCheckBox()
self.neuLabel.setSelected(chart.labelNeutral)
self.add(self.neuLabel)
change = JButton("Change")
change.setActionCommand("Change")
change.addActionListener(self)
pane.add(change)
exit = JButton("Exit")
exit.setActionCommand("Exit")
exit.addActionListener(self)
pane.add(exit)
self.pack()
示例3: __init__
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def __init__(self, frame, what, entries, pingFun):
JDialog(frame, what)
self.frame = frame
self.entries = entries
self.pingFun = pingFun
pane = self.getRootPane().getContentPane()
self.ent_pane, self.ent_list, self.ent = self.createList(entries)
pane.add(self.ent_pane, BorderLayout.WEST)
actionPanel = JPanel()
actionPanel.setLayout(GridLayout(20, 1))
self.text = JTextField(20)
actionPanel.add(self.text)
change = JButton('Change')
change.setActionCommand('Change')
change.addActionListener(self)
actionPanel.add(change)
actionPanel.add(JLabel(''))
quit = JButton('Exit')
quit.setActionCommand('Exit')
quit.addActionListener(self)
actionPanel.add(quit)
actionPanel.add(JLabel(''))
pane.add(actionPanel, BorderLayout.CENTER)
self.pack()
示例4: add_button
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def add_button(self, text, action):
index = len(self.actions)
name = "button%i" % index
button = JButton(text)
self.panel.add(button)
button.setActionCommand(name)
button.addActionListener(self)
self.actions[name] = action
return button
示例5: initGui
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def initGui(self):
def make_game_selector():
self.gameChanger = False
def dbChange(evt):
if evt.source.text:
self.gamedb = GameDB(evt.source.text)
self.gameChanger = True
def idChange(evt):
if evt.source.text:
self.gameid = evt.source.text
self.gameChanger = True
def turnChange(evt):
if evt.source.text:
self.turnid = evt.source.text
self.gameChanger = True
selector = JPanel()
selector.add(JLabel("DB:"))
selector.add(textfield(self.gamedb.dbfile, dbChange))
selector.add(JLabel("Game ID:"))
selector.add(textfield(self.gameid, idChange))
selector.add(JLabel("Turn ID:"))
selector.add(textfield(self.turnid, turnChange))
return JScrollPane(selector)
def make_content_panel():
self.contentPanel = JPanel(GridLayout(1, 0, 5, 5))
self.render()
return JScrollPane(self.contentPanel)
def save(self, txt, filename):
pass
def make_code_editor():
import inspect
panel = JPanel(BorderLayout(2,2))
self.codeArea = JTextArea()
self.codeArea.text = self.scoringModule and inspect.getsource(self.scoringModule) or ""
panel.add(JScrollPane(self.codeArea), BorderLayout.CENTER)
return panel
self.frame.contentPane.add(make_game_selector(), BorderLayout.NORTH)
# self.frame.contentPane.add(make_content_panel(), BorderLayout.WEST)
# self.frame.contentPane.add(make_code_editor(), BorderLayout.CENTER)
pane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT, make_content_panel(), make_code_editor())
pane.setDividerLocation(self.frame.width/2)
self.frame.contentPane.add(pane)
reloadButton = JButton("Reload")
def reload(evt):
self.reload()
reloadButton.addActionListener(reload)
self.frame.contentPane.add(reloadButton, BorderLayout.SOUTH)
示例6: makeScriptButton
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def makeScriptButton(button_name,script_name):
from javax.swing import JButton
from java.awt.event import ActionListener
btn = JButton(button_name)
#defin a class to invoke a script
# creating a class called action which does not exist
# this creates a python class deriving from ActionListener( a java class)
class action(ActionListener):
# defines a constructor
def __init__(self,sname):
self.sname = sname
def actionPerformed(self, event):
execfile(self.sname)
# registers an instance of the action object with the button
btn.addActionListener(action(script_name))
return btn
示例7: createSNTPanel
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def createSNTPanel():
# Create out control panel
panel = JPanel()
button = JButton("Run SNT")
panel.add(button)
panel.add(JButton("Remove panel", actionPerformed=removeSNTPanel))
op = OptionPanel()
layers = []
cal = front.getLayerSet().getCalibrationCopy()
for i, layer in enumerate(front.getLayerSet().getLayers()):
layers.append(str(i+1) + ": " + str(IJ.d2s(layer.getZ() * cal.pixelWidth, 2)))
c1 = op.addChoice("First section:", layers, 0, None)
c2 = op.addChoice("Last section:", layers, len(layers)-1)
button.addActionListener(Listener(c1, c2))
panel.add(op)
return panel
示例8: makeScriptComboBox
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def makeScriptComboBox(list):
from javax.swing import JComboBox, JButton, JPanel
from java.awt.event import ActionListener
jcb = JComboBox(list)
jcb.setSelectedIndex(0)
plot_btn = JButton("Plot station")
# create a Python class
class PlotButtonAction(ActionListener):
# defines a constructor
def __init__(self, combo_box):
self.cb = combo_box
def actionPerformed(self, event):
plotStation(self.cb.getSelectedIndex(), None)
# registers an instance of the action object with the button
plot_btn.addActionListener(PlotButtonAction(jcb))
#
alltw_btn = JButton("All Data")
class AllButtonAction(ActionListener):
# defines a constructor
def __init__(self, combo_box):
self.cb = combo_box
def actionPerformed(self, event):
plotStation(self.cb.getSelectedIndex(), 1)
alltw_btn.addActionListener(AllButtonAction(jcb))
#
quit_btn = JButton("Quit")
class QuitButtonAction(ActionListener):
# defines a constructor
def __init__(self, combo_box):
self.cb = combo_box
def actionPerformed(self, event):
fr.dispose()
quit_btn.addActionListener(QuitButtonAction(jcb))
# add both button and combo box to a panel
panel = JPanel()
panel.setLayout(GridLayout(2, 2))
panel.add(alltw_btn)
panel.add(jcb)
panel.add(plot_btn)
panel.add(quit_btn)
return panel
示例9: __init__
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def __init__(self, frame, what, all, removed, pingFun):
JDialog.__init__(self,frame, what)
self.frame = frame
self.all = all
self.removed = removed
self.pingFun = pingFun
pane = self.getRootPane().getContentPane()
self.sel_pane, self.sel_list, self.sel = self.createList(all)
pane.add(self.sel_pane, BorderLayout.WEST)
button_panel = JPanel()
button_panel.setLayout(GridLayout(8,1))
button_panel.add(JLabel('<-- Selected'))
button_panel.add(JLabel('Removed -->'))
select = JButton('Select')
select.setActionCommand('Select')
select.addActionListener(self)
button_panel.add(select)
button_panel.add(JLabel(''))
restrict = JButton('Remove')
restrict.setActionCommand('Remove')
restrict.addActionListener(self)
button_panel.add(restrict)
button_panel.add(JLabel(''))
quit = JButton('Exit')
quit.setActionCommand('Exit')
quit.addActionListener(self)
button_panel.add(quit)
button_panel.add(JLabel(''))
pane.add(button_panel, BorderLayout.CENTER)
self.rem_pane, self.rem_list, self.rem = self.createList(removed)
pane.add(self.rem_pane, BorderLayout.EAST)
warning_panel = JPanel()
warning_panel.add(JLabel("Warning: Removing/adding loci or pops might take some time!"))
pane.add(warning_panel, BorderLayout.NORTH)
self.pack()
示例10: __init__
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def __init__(self, frame, chart, lociNames, pv,
ci, confLines, locusFst, isDominant, fdr):
JDialog(frame)
self.chart = chart
self.frame = frame
self.confLines = confLines
self.isDominant = isDominant
self.fdr = fdr
pane = self.getRootPane().getContentPane()
pane.setLayout(BorderLayout())
self.initTable(lociNames, pv, ci, locusFst)
scrollPane = JScrollPane(self.table)
osName = System.getProperty('os.name').lower()
if not System.getProperty('java.specification.version')[-1] == '5':
self.table.setFillsViewportHeight(True)
pane.add(scrollPane, BorderLayout.CENTER)
buttonPane = JPanel()
sll = JButton('Save loci list')
sll.addActionListener(self)
sll.setActionCommand('SLL')
buttonPane.add(sll)
sci = JButton('Save confidence intervals')
sci.addActionListener(self)
sci.setActionCommand('SCI')
buttonPane.add(sci)
close = JButton('Close')
close.addActionListener(self)
close.setActionCommand('Close')
buttonPane.add(close)
pane.add(buttonPane, BorderLayout.PAGE_END)
self.pack()
示例11: __init__
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def __init__(self, callbacks, log):
self.callbacks = callbacks
self.log = log
self.log_table = None # to be set by caller
self.setLayout(BoxLayout(self, BoxLayout.PAGE_AXIS))
label = JLabel("Reload from Git Repo:")
button = JButton("Reload")
button.addActionListener(CommandPanel.ReloadAction(log))
self.add(label)
self.add(button)
label = JLabel("Send selected entries to respective Burp tools:")
button = JButton("Send")
button.addActionListener(CommandPanel.SendAction(self))
self.add(label)
self.add(button)
label = JLabel("Remove selected entries from Git Repo:")
button = JButton("Remove")
button.addActionListener(CommandPanel.RemoveAction(self, log))
self.add(label)
self.add(button)
示例12: createButton
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def createButton(text, command, manager):
button = JButton(text)
button.setActionCommand(command)
button.addActionListener(manager)
return button
示例13: JLabel
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
print roi_ni
choice_list = ["foo", "bar", "777"]
lbl1 = JLabel("foo label")
lbl2 = JLabel("bar label")
main_panel = JPanel()
### panel 1
panel1 = JPanel()
panel1.add(lbl1)
cb1 = JComboBox(choice_list)
btn1 = JButton("Accept")
btn1.addActionListener(ButtonListener(btn1))
panel1.add(cb1)
panel1.add(btn1)
### panel 2
panel2 = JPanel()
panel2.add(lbl2)
cb2 = JComboBox(sorted(roi_ni.keys()))
cb2.addActionListener(Listener(lbl2, cb2))
panel2.add(cb2)
### panel 3
pnl3 = JPanel()
lst1 = JList(listmodel)
pnl3.add(lst1)
示例14: __init__
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
def __init__(self, menuHandles, manager, isDominant, systemPanel, isTemporal=False):
self.systemPanel = systemPanel
self.knownPops = 0
self.ignoreChanges = True
JPanel()
self.menuHandles = menuHandles
self.isDominant = isDominant
self.isTemporal = isTemporal
if isDominant:
self.setLayout(GridLayout(8, 2))
else:
self.setLayout(GridLayout(5, 2))
if isTemporal:
self.add(JLabel("Ne"))
ne = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
ne.addPropertyChangeListener(self)
self.ne = ne
self.add(ne)
else:
self.add(JLabel("Attempted Fst"))
fst = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
fst.addPropertyChangeListener(self)
self.fst = fst
self.add(fst)
self.add(JLabel("Expected total pops"))
pops = JFormattedTextField(NumberFormat.getIntegerInstance(Locale.US))
pops.addPropertyChangeListener(self)
# self.pops = JComboBox(['1', '2', '4', '8', '12', '16'])
self.pops = pops
self.add(self.pops)
if not isDominant and not isTemporal:
self.add(JLabel("Mutation model"))
self.mut = JComboBox(["Infinite Alleles", "Stepwise"])
self.mut.addItemListener(self)
self.add(self.mut)
self.add(JLabel("Subsample size"))
sampleSize = JFormattedTextField(NumberFormat.getIntegerInstance(Locale.US))
sampleSize.addPropertyChangeListener(self)
self.sampleSize = sampleSize
self.add(self.sampleSize)
if isDominant:
self.add(JLabel("Theta"))
theta = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
theta.addPropertyChangeListener(self)
self.theta = theta
self.add(theta)
theta.setValue(0.1)
self.add(JLabel("Beta-a"))
beta1 = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
beta1.addPropertyChangeListener(self)
self.beta1 = beta1
self.add(beta1)
beta1.setValue(0.25)
self.add(JLabel("Beta-b"))
beta2 = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
beta2.addPropertyChangeListener(self)
self.beta2 = beta2
self.add(beta2)
beta2.setValue(0.25)
self.add(JLabel("Critical frequency"))
crit = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
crit.addPropertyChangeListener(self)
self.crit = crit
self.add(crit)
crit.setValue(0.99)
run = JButton("Run!")
run.addActionListener(manager)
run.setActionCommand("RunFDist")
self.run = run
self.add(run)
cancel = JButton("Stop")
cancel.addActionListener(manager)
cancel.setActionCommand("CancelFDist")
self.cancel = cancel
示例15: ButtonPanel
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addActionListener [as 别名]
class ButtonPanel(Panel):
playButton = None
helpButton = None
resetButton = None
exitButton = None
def __init__(self, inconsolePanel,dialogPanel):
self.consolePanel = inconsolePanel
self.dialogPanel = dialogPanel
Panel.__init__(self, "gap 1px 1px, insets 0 0 0 0, flowy")
def initUI(self):
self.setBackground(Color(0, 50, 0))
self.playButtonS = ImageIcon('bin/gui/media/' + "playButton.png")
self.helpButtonS = ImageIcon('bin/gui/media/' + "helpButton.png")
self.resetButtonS = ImageIcon('bin/gui/media/' + "resetButton.png")
self.exitButtonS = ImageIcon('bin/gui/media/' + "exitButton.png")
self.playButtonU = ImageIcon('bin/gui/media/' + "playButton_unselected.png")
self.helpButtonU = ImageIcon('bin/gui/media/' + "helpButton_unselected.png")
self.resetButtonU = ImageIcon('bin/gui/media/' + "resetButton_unselected.png")
self.exitButtonU = ImageIcon('bin/gui/media/' + "exitButton_unselected.png")
class MouseHoverAdap(MouseAdapter):
def __init__(self, butt, entImage, leaImage):
self.entImage = entImage
self.leaImage = leaImage
self.butt = butt
self.butt.setIcon(self.leaImage)
def mouseEntered(self, m):
self.butt.setIcon(self.entImage)
#self.butt.repaint()
def mouseExited(self, m):
self.butt.setIcon(self.leaImage)
#self.butt.repaint()
self.playButton = JButton(self.playButtonS)
self.playButton.setForeground(Color(0, 245, 0))
#self.playButton.setPreferredSize(Dimension(playButton.getIconWidth(), playButton.getIconHeight()))
#self.playButton.setBackground(Color(125, 125, 25))
self.playButton.setMaximumSize(Dimension(self.playButtonS.getIconWidth(), self.playButtonS.getIconHeight()))
self.playButton.setContentAreaFilled(False)
self.helpButton = JButton(self.helpButtonS)
self.helpButton.setForeground(Color(0, 235, 0))
self.helpButton.setMaximumSize(Dimension(self.helpButtonS.getIconWidth(), self.helpButtonS.getIconHeight()))
self.helpButton.setContentAreaFilled(False)
self.resetButton = JButton(self.resetButtonS)
self.resetButton.setForeground(Color(0, 225, 0))
self.resetButton.setMaximumSize(Dimension(self.resetButtonS.getIconWidth(), self.resetButtonS.getIconHeight()))
self.resetButton.setContentAreaFilled(False)
self.exitButton = JButton(self.exitButtonS)
self.exitButton.setForeground(Color(0, 215, 0))
self.exitButton.setContentAreaFilled(False)
self.exitButton.setMaximumSize(Dimension(self.exitButtonS.getIconWidth(), self.exitButtonS.getIconHeight()))
# self.playButton.addMouseListener(MouseHoverAdap(self.playButton, self.playButtonS, self.playButtonU))
# self.helpButton.addMouseListener(MouseHoverAdap(self.helpButton, self.helpButtonS, self.helpButtonU))
# self.resetButton.addMouseListener(MouseHoverAdap(self.resetButton, self.resetButtonS, self.resetButtonU))
# self.exitButton.addMouseListener(MouseHoverAdap(self.exitButton, self.exitButtonS, self.exitButtonU))
class PlayButtonActionListener(ActionListener):
def actionPerformed(button, e):
self.dialogPanel.speak(self.consolePanel.console.do_play(''))
self.playButton.addActionListener(PlayButtonActionListener())
class HelpBUttonActionListener(ActionListener):
def actionPerformed(button, e):
self.dialogPanel.speak(self.consolePanel.console.do_hint(''))
self.helpButton.addActionListener(HelpBUttonActionListener())
class ResetButtonActionListener(ActionListener):
def actionPerformed(button, e):
self.dialogPanel.speak(self.consolePanel.console.do_reset(''))
self.resetButton.addActionListener(ResetButtonActionListener())
class ExitButtonActionListener(ActionListener):
def actionPerformed(button, e):
System.exit(0)
self.exitButton.addActionListener(ExitButtonActionListener())
def addUI(self):
self.add(self.playButton, "push, grow")
self.add(self.helpButton, "push, grow")
self.add(self.resetButton, "push, grow")
self.add(self.exitButton, "push, grow")