本文整理汇总了Python中javax.swing.JTextField类的典型用法代码示例。如果您正苦于以下问题:Python JTextField类的具体用法?Python JTextField怎么用?Python JTextField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JTextField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DialogDemo
class DialogDemo(JDialog):
def __init__(self,table):
self.setTitle("Add Proxy")
self.setSize(200,100)
self.setVisible(True)
self.table = table
#self.getContentPane().add(about,BorderLayout.CENTER)
boxHorizontal = Box.createHorizontalBox()
boxVertical = Box.createVerticalBox()
boxHorizontal.add(JLabel("IP:"))
self.jIpText = JTextField(20)
boxHorizontal.add(self.jIpText)
boxVertical.add(boxHorizontal)
boxHorizontal = Box.createHorizontalBox()
boxHorizontal.add(JLabel("PROT:"))
self.jPortText = JTextField(20)
boxHorizontal.add(self.jPortText)
boxVertical.add(boxHorizontal)
boxHorizontal = Box.createHorizontalBox()
boxHorizontal.add(JButton("Add",actionPerformed=self.addIP))
boxVertical.add(boxHorizontal)
self.getContentPane().add(boxVertical,BorderLayout.CENTER)
def addIP(self,button):
TableModel = self.table.getModel()
TableModel.addRow([self.jIpText.getText(),self.jPortText.getText()])
示例2: 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
示例3: __init__
def __init__(self,table):
self.setTitle("Add Proxy")
self.setSize(200,100)
self.setVisible(True)
self.table = table
#self.getContentPane().add(about,BorderLayout.CENTER)
boxHorizontal = Box.createHorizontalBox()
boxVertical = Box.createVerticalBox()
boxHorizontal.add(JLabel("IP:"))
self.jIpText = JTextField(20)
boxHorizontal.add(self.jIpText)
boxVertical.add(boxHorizontal)
boxHorizontal = Box.createHorizontalBox()
boxHorizontal.add(JLabel("PROT:"))
self.jPortText = JTextField(20)
boxHorizontal.add(self.jPortText)
boxVertical.add(boxHorizontal)
boxHorizontal = Box.createHorizontalBox()
boxHorizontal.add(JButton("Add",actionPerformed=self.addIP))
boxVertical.add(boxHorizontal)
self.getContentPane().add(boxVertical,BorderLayout.CENTER)
示例4: HumanDetailPanel
class HumanDetailPanel(DetailPanel):
""" generated source for class HumanDetailPanel """
moveTable = JZebraTable()
moveTextField = JTextField()
selectButton = JButton()
selection = Move()
timerBar = JTimerBar()
def __init__(self):
""" generated source for method __init__ """
super(HumanDetailPanel, self).__init__(GridBagLayout())
model = DefaultTableModel()
model.addColumn("Legal Moves")
self.moveTable = JZebraTable(model)
self.selectButton = JButton(selectButtonMethod())
self.moveTextField = JTextField()
self.timerBar = JTimerBar()
self.selection = None
self.moveTable.setShowHorizontalLines(True)
self.moveTable.setShowVerticalLines(True)
self.moveTextField.setEditable(False)
self.add(JScrollPane(self.moveTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, Insets(5, 5, 5, 5), 5, 5))
self.add(self.selectButton, GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, Insets(5, 5, 5, 5), 0, 0))
self.add(self.moveTextField, GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, Insets(5, 5, 5, 5), 5, 5))
self.add(self.timerBar, GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, Insets(5, 5, 5, 5), 5, 5))
@overloaded
def observe(self, event):
""" generated source for method observe """
if isinstance(event, (HumanNewMovesEvent, )):
self.observe(event)
elif isinstance(event, (HumanTimeoutEvent, )):
self.observe(event)
elif isinstance(event, (PlayerTimeEvent, )):
self.observe(event)
@observe.register(object, HumanNewMovesEvent)
def observe_0(self, event):
""" generated source for method observe_0 """
model = self.moveTable.getModel()
model.setRowCount(0)
for move in event.getMoves():
model.addRow([None]*)
self.selection = event.getSelection()
self.moveTextField.setText(self.selection.__str__())
@observe.register(object, HumanTimeoutEvent)
def observe_1(self, event):
""" generated source for method observe_1 """
event.getHumanPlayer().setMove(self.selection)
@observe.register(object, PlayerTimeEvent)
def observe_2(self, event):
""" generated source for method observe_2 """
self.timerBar.time(event.getTime(), 500)
def selectButtonMethod(self):
""" generated source for method selectButtonMethod """
return AbstractAction("Select")
示例5: ConversationWindow
class ConversationWindow(Conversation):
"""A GUI window of a conversation with a specific person"""
def __init__(self, person, chatui):
"""ConversationWindow(basesupport.AbstractPerson:person)"""
Conversation.__init__(self, person, chatui)
self.mainframe = JFrame("Conversation with "+person.name)
self.display = JTextArea(columns=100,
rows=15,
editable=0,
lineWrap=1)
self.typepad = JTextField()
self.buildpane()
self.lentext = 0
def buildpane(self):
buttons = JPanel(doublebuffered)
buttons.add(JButton("Send", actionPerformed=self.send))
buttons.add(JButton("Hide", actionPerformed=self.hidewindow))
mainpane = self.mainframe.getContentPane()
mainpane.setLayout(BoxLayout(mainpane, BoxLayout.Y_AXIS))
mainpane.add(JScrollPane(self.display))
self.typepad.actionPerformed = self.send
mainpane.add(self.typepad)
mainpane.add(buttons)
def show(self):
self.mainframe.pack()
self.mainframe.show()
def hide(self):
self.mainframe.hide()
def sendText(self, text):
self.displayText("\n"+self.person.client.name+": "+text)
Conversation.sendText(self, text)
def showMessage(self, text, metadata=None):
self.displayText("\n"+self.person.name+": "+text)
def contactChangedNick(self, person, newnick):
Conversation.contactChangedNick(self, person, newnick)
self.mainframe.setTitle("Conversation with "+newnick)
#GUI code
def displayText(self, text):
self.lentext = self.lentext + len(text)
self.display.append(text)
self.display.setCaretPosition(self.lentext)
#actionlisteners
def hidewindow(self, ae):
self.hide()
def send(self, ae):
text = self.typepad.getText()
self.typepad.setText("")
if text != "" and text != None:
self.sendText(text)
示例6: textfield
def textfield(text = "", actionListener = None):
txt = JTextField(text, 15)
class Focuser(FocusListener):
def focusGained(self,e):
pass
def focusLost(self,e):
if actionListener: actionListener(e)
txt.addFocusListener(Focuser())
# if actionListener: txt.addActionListener(actionListener)
return txt
示例7: PrefsPanel
class PrefsPanel(JPanel):
"""JPanle with gui for tool preferences
"""
def __init__(self, app):
strings = app.strings
self.setLayout(GridLayout(3, 2, 5, 5))
userLbl = JLabel(strings.getString("osmose_pref_username"))
self.userTextField = JTextField(20)
self.userTextField.setToolTipText(strings.getString("osmose_pref_username_tooltip"))
levelLbl = JLabel(strings.getString("osmose_pref_level"))
self.levels = ["1", "1,2", "1,2,3", "2", "3"]
self.levelsCombo = JComboBox(self.levels)
self.levelsCombo.setToolTipText(strings.getString("osmose_pref_level_tooltip"))
limitLbl = JLabel(strings.getString("osmose_pref_limit"))
self.limitTextField = JTextField(20)
self.limitTextField.setToolTipText(strings.getString("osmose_pref_limit_tooltip"))
self.add(userLbl)
self.add(self.userTextField)
self.add(levelLbl)
self.add(self.levelsCombo)
self.add(limitLbl)
self.add(self.limitTextField)
def update_gui(self, preferences):
"""Update preferences gui
"""
self.userTextField.setText(preferences["username"])
self.levelsCombo.setSelectedIndex(self.levels.index(preferences["level"]))
self.limitTextField.setText(str(preferences["limit"]))
def read_gui(self):
"""Read preferences from gui
"""
username = self.userTextField.getText()
level = self.levelsCombo.getSelectedItem()
limit = self.limitTextField.getText()
try:
limit = Integer.parseInt(limit)
if limit > 500:
limit = 500
limit = str(limit)
except NumberFormatException:
limit = ""
preferences = {"username": username.strip(),
"level": level,
"limit": limit}
return preferences
示例8: build_working_dir_panel
def build_working_dir_panel(self, constraints, panel):
'''
Working directory row: label + field + button
This is for users to browse for their preferred default directory
when opening/creating a new file.
'''
working_dir_label = JLabel("Working directory:")
constraints = self.add_constraints(constraints, weightx=0.30,
gridx=0, gridy=0,
anchor=GridBagConstraints.EAST)
panel.add(working_dir_label, constraints)
self.wd_field = JTextField()
self.wd_field.setEditable(False)
# Can't find an elegant way to default to something that would be
# crossplatform, and I can't leave the default field empty.
if self.working_dir['default'] != "None":
self.wd_field.setText(self.working_dir['default'])
else:
self.wd_field.setText(os.getcwd())
constraints = self.add_constraints(constraints, weightx=0.60,
gridx=1, gridy=0,
fill=GridBagConstraints.HORIZONTAL,
insets=Insets(10, 10, 10, 5))
panel.add(self.wd_field, constraints)
constraints.fill = 0
button = JButton("Browse", actionPerformed=self.browse)
constraints = self.add_constraints(constraints, weightx=0.10,
gridx=2, gridy=0,
insets=Insets(10, 0, 10, 10))
panel.add(button, constraints)
示例9: registerExtenderCallbacks
def registerExtenderCallbacks(self,callbacks):
self.callbacks = callbacks
self.helpers = callbacks.getHelpers()
self.callbacks.setExtensionName("KkMultiProxy")
self.PROXY_LIST = []
self.jPanel = JPanel()
boxVertical = Box.createVerticalBox()
boxHorizontal = Box.createHorizontalBox()
boxHorizontal.add(JButton("File",actionPerformed=self.getFile))
self.FileText = JTextField("")
boxHorizontal.add(self.FileText)
boxVertical.add(boxHorizontal)
TableHeader = ('IP','PORT')
TableModel = DefaultTableModel(self.PROXY_LIST,TableHeader)
self.Table = JTable(TableModel)
boxVertical.add(self.Table)
boxHorizontal = Box.createHorizontalBox()
boxHorizontal.add(JButton("Add",actionPerformed=self.addIP))
boxHorizontal.add(JButton("Delete",actionPerformed=self.deleteIP))
boxHorizontal.add(JButton("Save",actionPerformed=self.saveIP))
boxVertical.add(boxHorizontal)
self.jPanel.add(boxVertical)
self.callbacks.addSuiteTab(self)
self.callbacks.registerHttpListener(self)
return
示例10: __init__
class _AccountAdder:
def __init__(self, contactslist):
self.contactslist = contactslist
self.mainframe = JFrame("Add New Contact")
self.account = JComboBox(self.contactslist.clientsByName.keys())
self.contactname = JTextField()
self.buildpane()
def buildpane(self):
buttons = JPanel()
buttons.add(JButton("OK", actionPerformed=self.add))
buttons.add(JButton("Cancel", actionPerformed=self.cancel))
acct = JPanel(GridLayout(1, 2), doublebuffered)
acct.add(JLabel("Account"))
acct.add(self.account)
mainpane = self.mainframe.getContentPane()
mainpane.setLayout(BoxLayout(mainpane, BoxLayout.Y_AXIS))
mainpane.add(self.contactname)
mainpane.add(acct)
mainpane.add(buttons)
self.mainframe.pack()
self.mainframe.show()
#action listeners
def add(self, ae):
acct = self.contactslist.clientsByName[self.account.getSelectedItem()]
acct.addContact(self.contactname.getText())
self.mainframe.dispose()
def cancel(self, ae):
self.mainframe.dispose()
示例11: EditSymbolAttr
class EditSymbolAttr(JPanel):
def __init__(self, sattr):
self.attr = sattr
self.cbox = JColorChooser(self.attr.color)
self.sz_field = JTextField(str(self.attr.size))
szpanel = JPanel()
szpanel.add(self.sz_field)
szpanel.setBorder(BorderFactory.createTitledBorder("symbol size (integer)"))
self.filled_box = JCheckBox("Filled ?:",self.attr.filled)
self.shape_cbox = JComboBox(SymbolProps.sym_shape_map.keys())
self.shape_cbox.setSelectedItem(self.attr.shape)
self.shape_cbox.setBorder(BorderFactory.createTitledBorder("Shape"))
panel1 = JPanel()
panel1.setLayout(BorderLayout())
panel1.add(szpanel,BorderLayout.NORTH)
panel2 = JPanel()
panel2.setLayout(GridLayout(1,2))
panel2.add(self.shape_cbox)
panel2.add(self.filled_box)
panel1.add(panel2,BorderLayout.SOUTH)
self.setLayout(BorderLayout())
self.add(self.cbox,BorderLayout.CENTER)
self.add(panel1,BorderLayout.SOUTH)
def setAttribute(self,sattr):
self.attr = sattr
self.cbox.color = self.attr.color
self.sz_field.text = str(self.attr.size)
self.shape_cbox.setSelectedItem(self.attr.shape)
def update(self):
self.attr.color = self.cbox.getColor()
self.attr.size = string.atoi(self.sz_field.getText())
self.attr.filled = self.filled_box.isSelected()
self.attr.shape = self.shape_cbox.getSelectedItem()
self.attr.sym = self.attr.createSymbol()
示例12: __init__
def __init__(self, p):
self.cellCounter = 1
self.olay = Overlay()
self.position = p
print p.getRoiPath()
if p.getRoiPath() != None: # check if there is an existing overlay file and load it!
p.loadRois()
self.frame = JFrame("CellCropper", size=(200,200))
self.frame.setLocation(20,120)
self.Panel = JPanel(GridLayout(0,1))
self.frame.add(self.Panel)
#self.nameField = JTextField("p" + "_c",15)
self.nameField = JTextField("p" + str(self.position.getID()) + "_c",15)
self.Panel.add(self.nameField)
self.cutoutButton = JButton("Cut out cell",actionPerformed=cut)
self.Panel.add(self.cutoutButton)
self.delOlButton = JButton("Delete Overlay",actionPerformed=delOverlay)
self.Panel.add(self.delOlButton)
self.saveOlButton = JButton("Save Overlay",actionPerformed=saveOverlay)
self.Panel.add(self.saveOlButton)
self.quitButton = JButton("Quit script",actionPerformed=quit)
self.Panel.add(self.quitButton)
self.frame.pack()
WindowManager.addWindow(self.frame)
self.show()
示例13: initUI
def initUI(self):
self.panel = JPanel(size=(50,50))
self.panel.setLayout(FlowLayout( ))
self.panel.setToolTipText("GPU Demo")
#TODO- change this so that it deletes itself when text is entered
self.textfield1 = JTextField('Smoothing Parameter',15)
self.panel.add(self.textfield1)
joclButton = JButton("JOCL",actionPerformed=self.onJocl)
joclButton.setBounds(100, 500, 100, 30)
joclButton.setToolTipText("JOCL Button")
self.panel.add(joclButton)
javaButton = JButton("Java",actionPerformed=self.onJava)
javaButton.setBounds(100, 500, 100, 30)
javaButton.setToolTipText("Java Button")
self.panel.add(javaButton)
qButton = JButton("Quit", actionPerformed=self.onQuit)
qButton.setBounds(200, 500, 80, 30)
qButton.setToolTipText("Quit Button")
self.panel.add(qButton)
newImage = ImageIO.read(io.File(getDataDir() + "input.png"))
resizedImage = newImage.getScaledInstance(600, 600,10)
newIcon = ImageIcon(resizedImage)
label1 = JLabel("Input Image",newIcon, JLabel.CENTER)
label1.setVerticalTextPosition(JLabel.TOP)
label1.setHorizontalTextPosition(JLabel.RIGHT)
label1.setSize(10,10)
label1.setBackground(Color.orange)
self.panel.add(label1)
self.getContentPane().add(self.panel)
self.clockLabel = JLabel()
self.clockLabel.setSize(1,1)
self.clockLabel.setBackground(Color.orange)
self.clockLabel.setVerticalTextPosition(JLabel.BOTTOM)
self.clockLabel.setHorizontalTextPosition(JLabel.LEFT)
myClockFont = Font("Serif", Font.PLAIN, 50)
self.clockLabel.setFont(myClockFont)
self.panel.add(self.clockLabel)
self.setTitle("Structure-oriented smoothing OpenCL Demo")
self.setSize(1200, 700)
self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
self.setLocationRelativeTo(None)
self.setVisible(True)
示例14: initGui
def initGui(self):
#~ if DEBUG:
#~ import pdb;
#~ pdb.set_trace()
tabPane = JTabbedPane(JTabbedPane.TOP)
CreditsText = "<html># Burp Custom Deserializer<br/># Copyright (c) 2016, Marco Tinari<br/>#<br/># This program is free software: you can redistribute it and/or modify<br/># it under the terms of the GNU General Public License as published by<br/># the Free Software Foundation, either version 3 of the License, or<br/># (at your option) any later version.<br/>#<br/># This program is distributed in the hope that it will be useful,<br/># but WITHOUT ANY WARRANTY; without even the implied warranty of<br/># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br/># GNU General Public License for more details.<br/>#<br/># You should have received a copy of the GNU General Public License<br/># along with this program. If not, see <http://www.gnu.org/licenses/>.)<br/></html>"
label1 = JLabel("<html>Usage:<br>1 - Select the desired encoding functions<br>2 - Enter the name of the parameter in the input field below and press the Apply button!</html>")
label2 = JLabel(CreditsText)
panel1 = JPanel()
#set layout
panel1.setLayout(GridLayout(11,1))
panel2 = JPanel()
panel1.add(label1)
panel2.add(label2)
tabPane.addTab("Configuration", panel1)
tabPane.addTab("Credits", panel2)
applyButton = JButton('Apply',actionPerformed=self.reloadConf)
panel1.add(applyButton, BorderLayout.SOUTH)
#define GET/POST/COOKIE radio button
self.GETparameterTypeRadioButton = JRadioButton('GET parameter')
self.POSTparameterTypeRadioButton = JRadioButton('POST parameter')
self.COOKIEparameterTypeRadioButton = JRadioButton('COOKIE parameter')
self.POSTparameterTypeRadioButton.setSelected(True)
group = ButtonGroup()
group.add(self.GETparameterTypeRadioButton)
group.add(self.POSTparameterTypeRadioButton)
group.add(self.COOKIEparameterTypeRadioButton)
self.base64Enabled = JCheckBox("Base64 encode")
self.URLEnabled = JCheckBox("URL encode")
self.ASCII2HexEnabled = JCheckBox("ASCII to Hex")
self.ScannerEnabled = JCheckBox("<html>Enable serialization in Burp Scanner<br>Usage:<br>1.Place unencoded values inside intruder request and define the placeholder positions<br>2.rightclick->Actively scan defined insertion points)</html>")
self.IntruderEnabled = JCheckBox("<html>Enable serialization in Burp Intruder<br>Usage:<br>1.Place unencoded values inside intruder request and define the placeholder positions<br>2.Start the attack</html>")
self.parameterName = JTextField("Parameter name goes here...",60)
#set the tooltips
self.parameterName.setToolTipText("Fill in the parameter name and apply")
self.base64Enabled.setToolTipText("Enable base64 encoding/decoding")
self.ASCII2HexEnabled.setToolTipText("Enable ASCII 2 Hex encoding/decoding")
self.URLEnabled.setToolTipText("Enable URL encoding/decoding")
self.IntruderEnabled.setToolTipText("Check this if You want the extension to intercept and modify every request made by the Burp Intruder containing the selected paramter")
self.ScannerEnabled.setToolTipText("Check this if You want the extension to intercept and modify every request made by the Burp Scanner containing the selected paramter")
#add checkboxes to the panel
panel1.add(self.parameterName)
panel1.add(self.POSTparameterTypeRadioButton)
panel1.add(self.GETparameterTypeRadioButton)
panel1.add(self.COOKIEparameterTypeRadioButton)
panel1.add(self.base64Enabled)
panel1.add(self.URLEnabled)
panel1.add(self.ASCII2HexEnabled)
panel1.add(self.IntruderEnabled)
panel1.add(self.ScannerEnabled)
#assign tabPane
self.tab = tabPane
示例15: loadStiData
def loadStiData(idv):
hostField = JTextField('',30);
userField = JTextField('',30);
passwordField = JPasswordField('',30);
comps = ArrayList();
comps.add(JLabel("Database Host:"));
comps.add(GuiUtils.inset(hostField,4));
comps.add(JLabel("User Name:"));
comps.add(GuiUtils.inset(userField,5));
comps.add(JLabel("Password:"));
comps.add(GuiUtils.inset(passwordField,5));
contents = GuiUtils.doLayout(comps, 2,GuiUtils.WT_N, GuiUtils.WT_N);
contents =GuiUtils.inset(contents,5);
ok = GuiUtils.showOkCancelDialog(None,'foo', contents, None);
if(ok==0):
return;
url = 'jdbc:mysql://' + hostField.getText() +':3306/typhoon?zeroDateTimeBehavior=convertToNull&user=' + userField.getText() +'&password=' + passwordField.getText();
print(url);
idv.makeOneDataSource(url,'DB.STORMTRACK', None);