本文整理汇总了Python中javax.swing.JButton类的典型用法代码示例。如果您正苦于以下问题:Python JButton类的具体用法?Python JButton怎么用?Python JButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tree
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
def init(self):
global exampleList
self.thinFont = Font("Dialog", 0, 10)
self.pane = self.getContentPane()
self.examples = exampleList.keys()
self.examples.sort()
self.exampleSelector = JList(self.examples, valueChanged=self.valueChanged)
self.exampleSelector.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
self.exampleSelector.setLayoutOrientation(JList.VERTICAL)
self.exampleSelector.setPreferredSize(Dimension(150,500))
self.exampleSelector.setBackground(Color(0.95, 0.95, 0.98))
self.exampleSelector.setFont(self.thinFont)
self.centerPanel = JPanel(BorderLayout())
self.canvas = GraphCanvas()
self.canvas.setApplet(self)
self.buttonRow = JPanel(FlowLayout())
self.backButton = JButton("<", actionPerformed = self.backAction)
self.backButton.setFont(self.thinFont)
self.continueButton = JButton("continue >",
actionPerformed=self.continueAction)
self.continueButton.setFont(self.thinFont)
self.scaleGroup = ButtonGroup()
self.linearButton = JRadioButton("linear scale",
actionPerformed=self.linearAction)
self.linearButton.setSelected(True)
self.linearButton.setFont(self.thinFont)
self.logarithmicButton = JRadioButton("logarithmic scale",
actionPerformed=self.logarithmicAction)
self.logarithmicButton.setFont(self.thinFont)
self.aboutButton = JButton("About...",
actionPerformed=self.aboutAction)
self.aboutButton.setFont(self.thinFont)
self.scaleGroup.add(self.linearButton)
self.scaleGroup.add(self.logarithmicButton)
self.buttonRow.add(self.backButton)
self.buttonRow.add(self.continueButton)
self.buttonRow.add(JLabel(" "*5))
self.buttonRow.add(self.linearButton)
self.buttonRow.add(self.logarithmicButton)
self.buttonRow.add(JLabel(" "*20));
self.buttonRow.add(self.aboutButton)
self.centerPanel.add(self.canvas, BorderLayout.CENTER)
self.centerPanel.add(self.buttonRow, BorderLayout.PAGE_END)
self.helpText = JTextPane()
self.helpText.setBackground(Color(1.0, 1.0, 0.5))
self.helpText.setPreferredSize(Dimension(800,80))
self.helpText.setText(re_sub("[ \\n]+", " ", """
Please select one of the examples in the list on the left!
"""))
self.pane.add(self.exampleSelector, BorderLayout.LINE_START)
self.pane.add(self.centerPanel, BorderLayout.CENTER)
self.pane.add(self.helpText, BorderLayout.PAGE_END)
self.graph = None
self.simulation = None
self.touched = ""
self.selected = ""
self.gfxDriver = None
示例3: __init__
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: init
def init(self):
jbNew= JButton( LoadDefaultXmlThrottlesLayoutAction() )
jbNew.setIcon( NamedIcon("resources/Throttles.gif","resources/Throttles.gif") )
jbNew.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
jbNew.setToolTipText( jbNew.getText() )
jbNew.setText( None )
self.add(jbNew)
示例5: __init__
def __init__(self, parent, title, modal, app):
JDialog.__init__(self, parent, title, modal)
#Download and Read Dialog
border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
self.getContentPane().setBorder(border)
self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))
panel = JPanel()
panel.setAlignmentX(0.5)
panel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))
panel.add(Box.createRigidArea(Dimension(0, 10)))
self.progressLbl = JLabel(app.strings.getString("downloading_and_reading_errors"))
panel.add(self.progressLbl)
panel.add(Box.createRigidArea(Dimension(0, 10)))
self.progressBar = JProgressBar(0, 100, value=0)
panel.add(self.progressBar)
self.add(panel)
self.add(Box.createRigidArea(Dimension(0, 20)))
cancelBtn = JButton(app.strings.getString("cancel"),
ImageProvider.get("cancel"),
actionPerformed=app.on_cancelBtn_clicked)
cancelBtn.setAlignmentX(0.5)
self.add(cancelBtn)
self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
self.pack()
示例6: DCCThrottle
class DCCThrottle(Jynstrument, PropertyChangeListener, AddressListener, jmri.ThrottleListener):
#Jynstrument main and mandatory methods
def getExpectedContextClassName(self):
return "jmri.jmrit.throttle.ThrottleWindow"
def init(self):
self.getContext().addPropertyChangeListener(self) #ThrottleFrame change
self.addressPanel = self.getContext().getCurrentThrottleFrame().getAddressPanel()
self.addressPanel.addAddressListener(self) # change of throttle in Current frame
self.panelThrottle = self.getContext().getCurrentThrottleFrame().getAddressPanel().getThrottle() # the throttle
self.label = JButton(ImageIcon(self.getFolder() + "/DCCThrottle.png","DCCThrottle")) #label
self.label.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
self.add(self.label)
# create a dcc throttle and request one from the ThrottleManager
self.masterThrottle = None
if ( jmri.InstanceManager.throttleManagerInstance().requestThrottle(listenToDCCThrottle, self) == False):
print "Couldn't request a throttle for "+locoAddress
# Advanced functions
self.advFunctions = AdvFunctions()
def quit(self):
if (self.masterThrottle != None):
self.masterThrottle.removePropertyChangeListener(self)
self.masterThrottle = None
self.panelThrottle = None
self.advFunctions = None
if (self.addressPanel != None):
self.addressPanel.removeAddressListener(self)
self.addressPanel = None
self.getContext().removePropertyChangeListener(self)
示例7: init
def init(self):
jbNew = JButton( PaneOpsProgAction() )
jbNew.setIcon( NamedIcon("resources/decoderpro.gif","resources/decoderpro.gif") )
jbNew.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
jbNew.setToolTipText( jbNew.getText() )
jbNew.setText( None )
self.add(jbNew)
示例8: add_template
def add_template(self,name,constructor,image):
icon = ImageIcon(image)
if icon.iconWidth>self.max_icon_width:
icon = ImageIcon(icon.image.getScaledInstance(self.max_icon_width,icon.iconHeight*self.max_icon_width/icon.iconWidth,Image.SCALE_SMOOTH))
panel = JPanel(layout = BorderLayout(),opaque = False)
button = JButton(icon = icon,toolTipText = name.replace('\n',' '),
borderPainted = False,focusPainted = False,contentAreaFilled = False,margin = java.awt.Insets(0,0,0,0),
verticalTextPosition = AbstractButton.BOTTOM,horizontalTextPosition = AbstractButton.CENTER,
mousePressed = lambda e: e.source.transferHandler.exportAsDrag(e.source,e,TransferHandler.COPY))
button.transferHandler = self
panel.add(button)
text = '<html><center>%s</center></html>'%name.replace('\n','<br/>')
label = JLabel(text,horizontalAlignment = SwingConstants.CENTER,foreground = Color.WHITE)
self.labels.append(label)
panel.add(label,BorderLayout.SOUTH)
self.panels.append(panel)
panel.alignmentY = Component.CENTER_ALIGNMENT
panel.border = BorderFactory.createEmptyBorder(2,1,2,1)
panel.maximumSize = panel.preferredSize
self.panel.add(panel)
self.templates[button] = constructor
示例9: handle
def handle(self):
print 'connection from', self.client_address
conn = self.request
while 1:
msg = conn.recv(20)
if msg == "keymap":
print "keymapping!"
keymapFrame = JFrame('Key Mapping Configuration',
defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
size = (300, 500)
)
keyButton = JButton('Press any key in iPhone')
keymapFrame.add(keyButton)
keymapFrame.visible = True
while 1:
recvKey = conn.recv(20)
keyButton.setLabel("%s?" % recvKey)
keyInput = raw_input()
keynum[recvKey] = keyInput
keyButton.setText('Press any key in iPhone')
if recvKey == "keymap":
keymapFrame.visible = False
break
if msg == "quit()":
conn.close()
print self.client_address, 'disconnected'
break
print self.client_address, msg
示例10: __init__
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()
示例11: getControlPanel
def getControlPanel():
global controlPanel
controlPanel = JPanel()
controlPanel.setLayout(BoxLayout(controlPanel, BoxLayout.Y_AXIS))
for row in keyLayout:
rowPanel = JPanel()
rowPanel.setLayout(BoxLayout(rowPanel, BoxLayout.X_AXIS))
controlPanel.add(rowPanel)
for key in row:
button = JButton(key[0], actionPerformed=handleKeyButton)
button.setActionCommand(key[1])
rowPanel.add(button)
global terminalResult
terminalResult = JTextArea()
scroller = JScrollPane(terminalResult)
terminalResult.setLineWrap(True)
scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS)
scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)
controlPanel.add(scroller)
global terminalInput
termInputPanel = JPanel()
termInputPanel.setLayout(BoxLayout(termInputPanel, BoxLayout.X_AXIS))
termInputLabel = JLabel("Command")
termInputPanel.add(termInputLabel)
terminalInput = JTextField(actionPerformed=handleTerminalInput)
minimumSize = terminalInput.getMinimumSize()
maximumSize = terminalInput.getMaximumSize()
terminalInput.setMaximumSize(Dimension(maximumSize.width, minimumSize.height))
termInputPanel.add(terminalInput)
controlPanel.add(termInputPanel)
return controlPanel
示例12: add_button
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
示例13: make_button
def make_button(label, tooltip_text, icon_file_path=None):
"""Returns a JButton"""
button = JButton()
button.actionCommand = label
button.toolTipText = tooltip_text
if icon_file_path:
button.icon = ImageIcon(icon_file_path, tooltip_text.upper())
else:
button.text = label
return button
示例14: loadPanel
def loadPanel(self):
panel = JPanel()
panel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))
bottomButtonBarPanel = JPanel()
bottomButtonBarPanel.setLayout(BoxLayout(bottomButtonBarPanel, BoxLayout.X_AXIS))
bottomButtonBarPanel.setAlignmentX(1.0)
self.runButton = JButton("Run", actionPerformed=self.start)
self.cancelButton = JButton("Close", actionPerformed=self.cancel)
bottomButtonBarPanel.add(Box.createHorizontalGlue());
bottomButtonBarPanel.add(self.runButton)
bottomButtonBarPanel.add(self.cancelButton)
# Dimension(width,height)
bottom = JPanel()
bottom.setLayout(BoxLayout(bottom, BoxLayout.X_AXIS))
bottom.setAlignmentX(1.0)
self.progressBar = JProgressBar()
self.progressBar.setIndeterminate(False)
self.progressBar.setMaximum(100)
self.progressBar.setValue(0)
bottom.add(self.progressBar)
self.statusTextArea = JTextArea()
self.statusTextArea.setEditable(False)
scrollPane = JScrollPane(self.statusTextArea)
scrollPanel = JPanel()
scrollPanel.setLayout(BoxLayout(scrollPanel, BoxLayout.X_AXIS))
scrollPanel.setAlignmentX(1.0)
scrollPanel.add(scrollPane)
panel.add(scrollPanel)
panel.add(bottomButtonBarPanel)
panel.add(bottom)
self.add(panel)
self.setTitle("Determine Session Cookie(s)")
self.setSize(450, 300)
self.setLocationRelativeTo(None)
self.setVisible(True)
original_request_bytes = self.selected_message.getRequest()
http_service = self.selected_message.getHttpService()
helpers = self.callbacks.getHelpers()
request_info = helpers.analyzeRequest(http_service, original_request_bytes)
parameters = request_info.getParameters();
cookie_parameters = [parameter for parameter in parameters if parameter.getType() == IParameter.PARAM_COOKIE]
num_requests_needed = len(cookie_parameters) + 2
self.statusTextArea.append("This may require up to " + str(num_requests_needed) + " requests to be made. Hit 'Run' to begin.\n")
示例15: initConfigurationTab
def initConfigurationTab(self):
#
## init configuration tab
#
self.prevent304 = JCheckBox("Prevent 304 Not Modified status code")
self.prevent304.setBounds(290, 25, 300, 30)
self.ignore304 = JCheckBox("Ignore 304/204 status code responses")
self.ignore304.setBounds(290, 5, 300, 30)
self.ignore304.setSelected(True)
self.autoScroll = JCheckBox("Auto Scroll")
#self.autoScroll.setBounds(290, 45, 140, 30)
self.autoScroll.setBounds(160, 40, 140, 30)
self.doUnauthorizedRequest = JCheckBox("Check unauthenticated")
self.doUnauthorizedRequest.setBounds(290, 45, 300, 30)
self.doUnauthorizedRequest.setSelected(True)
startLabel = JLabel("Authorization checks:")
startLabel.setBounds(10, 10, 140, 30)
self.startButton = JButton("Autorize is off",actionPerformed=self.startOrStop)
self.startButton.setBounds(160, 10, 120, 30)
self.startButton.setBackground(Color(255, 100, 91, 255))
self.clearButton = JButton("Clear List",actionPerformed=self.clearList)
self.clearButton.setBounds(10, 40, 100, 30)
self.replaceString = JTextArea("Cookie: Insert=injected; header=here;", 5, 30)
self.replaceString.setWrapStyleWord(True);
self.replaceString.setLineWrap(True)
self.replaceString.setBounds(10, 80, 470, 180)
self.filtersTabs = JTabbedPane()
self.filtersTabs.addTab("Enforcement Detector", self.EDPnl)
self.filtersTabs.addTab("Detector Unauthenticated", self.EDPnlUnauth)
self.filtersTabs.addTab("Interception Filters", self.filtersPnl)
self.filtersTabs.addTab("Export", self.exportPnl)
self.filtersTabs.setBounds(0, 280, 2000, 700)
self.pnl = JPanel()
self.pnl.setBounds(0, 0, 1000, 1000);
self.pnl.setLayout(None);
self.pnl.add(self.startButton)
self.pnl.add(self.clearButton)
self.pnl.add(self.replaceString)
self.pnl.add(startLabel)
self.pnl.add(self.autoScroll)
self.pnl.add(self.ignore304)
self.pnl.add(self.prevent304)
self.pnl.add(self.doUnauthorizedRequest)
self.pnl.add(self.filtersTabs)