本文整理汇总了Python中javax.swing.JTextField.getText方法的典型用法代码示例。如果您正苦于以下问题:Python JTextField.getText方法的具体用法?Python JTextField.getText怎么用?Python JTextField.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextField
的用法示例。
在下文中一共展示了JTextField.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DialogDemo
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
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: PrefsPanel
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
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
示例3: EditSymbolAttr
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
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()
示例4: __init__
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
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()
示例5: ConversationWindow
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
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: initUI
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
def initUI(self):
global outputTextField
self.panel = JPanel()
self.panel.setLayout(BorderLayout())
toolbar = JToolBar()
openb = JButton("Choose input file", actionPerformed=self.onClick)
outputLabel = JLabel(" Enter output file name: ")
outputTextField = JTextField("hl7OutputReport.txt", 5)
print outputTextField.getText()
toolbar.add(openb)
toolbar.add(outputLabel)
toolbar.add(outputTextField)
self.area = JTextArea()
self.area.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
self.area.setText("Select your HL7 ORU messages text file to be converted to tab-delimited flat \nfile with select HL7 fields.\n")
self.area.append("You can enter the path + file name for your output file or it will default to the current \nfile name in the text field above in your current working directory.")
pane = JScrollPane()
pane.getViewport().add(self.area)
self.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
self.panel.add(pane)
self.add(self.panel)
self.add(toolbar, BorderLayout.NORTH)
self.setTitle("HL7 ORU Results Reporter")
self.setSize(600, 300)
self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
self.setLocationRelativeTo(None)
self.setVisible(True)
return outputTextField.getText()
示例7: loadStiData
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
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);
示例8: SwingLoginDialog
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
class SwingLoginDialog(JDialog):
def __init__(self):
self.username=""
self.password=""
self.okPressed=False
self.userField=JTextField(15)
self.passField=JPasswordField(15)
self.setTitle("Login")
self.setModal(True)
self.setAlwaysOnTop(True)
self.setLocationRelativeTo(None)
pane = self.getContentPane()
pane.setLayout(GridLayout(4,2))
pane.add(JLabel("Username:"))
pane.add(self.userField)
pane.add(JLabel("Password:"))
pane.add(self.passField)
pane.add(JLabel())
pane.add(JLabel())
okButton = JButton("OK", actionPerformed=self.okClick)
pane.add(okButton)
cancelButton=JButton("Cancel", actionPerformed=self.cancelClick)
pane.add(cancelButton)
self.pack()
def okClick(self, e):
self.okPressed=True
self.username=self.userField.getText()
self.password=str(String(self.passField.getPassword()))
self.setVisible(False)
def cancelClick(self, e):
self.okPressed=False
self.setVisible(False)
def getLoginInfo(self):
if self.okPressed:
return [self.username, self.password]
return None
示例9: changeDomainPopup
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
def changeDomainPopup(self, oldDomain, index):
hostField = JTextField(25)
checkbox = JCheckBox()
domainPanel = JPanel(GridLayout(0,1))
domainPanel.add(JLabel("Request %s: Domain %s inaccessible. Enter new domain." % (str(index),oldDomain)))
firstline = JPanel()
firstline.add(JLabel("Host:"))
firstline.add(hostField)
domainPanel.add(firstline)
secondline = JPanel()
secondline.add(JLabel("Replace domain for all requests?"))
secondline.add(checkbox)
domainPanel.add(secondline)
result = JOptionPane.showConfirmDialog(
self._splitpane,domainPanel, "Domain Inaccessible", JOptionPane.OK_CANCEL_OPTION)
cancelled = (result == JOptionPane.CANCEL_OPTION)
if cancelled:
return (False, None, False)
return (True, hostField.getText(), checkbox.isSelected())
示例10: getArguments
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
#.........这里部分代码省略.........
constraints.gridx = 0
constraints.gridy = 0
constraints.gridwidth = 1
constraints.gridheight = 1
constraints.fill = GridBagConstraints.HORIZONTAL
constraints.weightx = 0
constraints.weighty = 0
contentPane.add(JLabel("Blast Location"), constraints)
constraints.gridy = 1
contentPane.add(JLabel("Genemark Location"), constraints)
constraints.gridy = 2
contentPane.add(JLabel("Transterm Location"), constraints)
constraints.gridy = 3
contentPane.add(JLabel("tRNAscan Location"), constraints)
constraints.gridy = 4
contentPane.add(JLabel("Databases Location"), constraints)
constraints.gridy = 5
contentPane.add(JLabel("Database"), constraints)
constraints.gridy = 6
contentPane.add(JLabel("Matrix(Leave blank to use heuristic matrix)"), constraints)
constraints.gridy = 7
contentPane.add(JLabel("E Value"), constraints)
constraints.gridy = 8
contentPane.add(JLabel("Minimum Intergenic Length"), constraints)
constraints.gridy = 9
contentPane.add(JLabel("Scaffold Distance"), constraints)
constraints.gridy = 10
contentPane.add(JLabel("Promoter Score Cutoff"), constraints)
constraints.gridy = 11
contentPane.add(JLabel("Query"), constraints)
constraints.gridx = 1
constraints.gridy = 0
constraints.weightx = 1
contentPane.add(blastField, constraints)
constraints.gridy = 1
contentPane.add(genemarkField, constraints)
constraints.gridy = 2
contentPane.add(transtermField, constraints)
constraints.gridy = 3
contentPane.add(tRNAscanField, constraints)
constraints.gridy = 4
contentPane.add(databaseLocationField, constraints)
constraints.gridy = 5
contentPane.add(databaseField, constraints)
constraints.gridy = 6
contentPane.add(matrixField, constraints)
constraints.gridy = 7
contentPane.add(eValueField, constraints)
constraints.gridy = 8
contentPane.add(minLengthField, constraints)
constraints.gridy = 9
contentPane.add(scaffoldingDistanceField, constraints)
constraints.gridy = 10
contentPane.add(promoterScoreField, constraints)
constraints.gridy = 11
contentPane.add(queryField, constraints)
constraints.gridx = 2
constraints.gridy = 0
constraints.weightx = 0
constraints.fill = GridBagConstraints.NONE
constraints.anchor = GridBagConstraints.LINE_END
contentPane.add(JButton(LocationAction(blastField)), constraints)
constraints.gridy = 1
contentPane.add(JButton(LocationAction(genemarkField)), constraints)
constraints.gridy = 2
contentPane.add(JButton(LocationAction(transtermField)), constraints)
constraints.gridy = 3
contentPane.add(JButton(LocationAction(tRNAscanField)), constraints)
constraints.gridy = 4
contentPane.add(JButton(LocationAction(databaseLocationField)), constraints)
constraints.gridy = 11
contentPane.add(JButton(LocationAction(queryField)), constraints)
constraints.gridx = 0
constraints.gridy = 12
constraints.anchor = GridBagConstraints.LINE_START
contentPane.add(JButton(HelpAction()), constraints)
constraints.gridx = 1
constraints.anchor = GridBagConstraints.LINE_END
contentPane.add(JButton(OKAction()), constraints)
constraints.gridx = 2
contentPane.add(JButton(CancelAction()), constraints)
frame.pack()
frame.setLocationRelativeTo(None)
frame.setVisible(True)
while frame.isVisible():
pass
self.blastLocation = blastField.getText()
self.genemarkLocation = genemarkField.getText()
self.transtermLocation = transtermField.getText()
self.database = databaseLocationField.getText() + "/" + databaseField.getText()
self.matrix = matrixField.getText()
self.eValue = float(eValueField.getText())
self.minLength = int(minLengthField.getText())
self.scaffoldingDistance = int(scaffoldingDistanceField.getText())
self.promoterScoreCutoff = float(promoterScoreField.getText())
self.sources = [queryField.getText()]
示例11: ConfigurationPanel
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
#.........这里部分代码省略.........
c.fill = GridBagConstraints.HORIZONTAL
c.weightx = 0.5
c.gridwidth = 2
c.gridx = 0
c.gridy = 7
self.add(bSaveCfg, c)
self.bSimulation= JButton('Load Configuration', actionPerformed= self.loadConfiguration)
c = GridBagConstraints()
c.fill = GridBagConstraints.HORIZONTAL
c.weightx = 0.5
c.gridwidth = 2
c.gridx = 2
c.gridy = 7
self.add(self.bSimulation, c)
''' fila 8 '''
self.bSimulation= JButton('Simulate', actionPerformed= self.startSimlation)
self.bSimulation.enabled= 0
c = GridBagConstraints()
c.fill = GridBagConstraints.HORIZONTAL
c.weightx = 1
c.gridwidth = 4
c.gridx = 0
c.gridy = 8
self.add(self.bSimulation, c)
''' file 9 '''
simProgress= JProgressBar(0, self.getWidth(), value=0, stringPainted=True)
c = GridBagConstraints()
c.fill = GridBagConstraints.HORIZONTAL
c.weightx = 1
c.gridwidth = 4
c.gridx = 0
c.gridy = 9
self.add(simProgress, c)
''' fila 10 '''
self.lblResult= JLabel('Simulation information')
c = GridBagConstraints()
c.fill = GridBagConstraints.HORIZONTAL
c.weightx = 1
c.gridwidth = 4
c.gridx = 0
c.gridy = 10
self.add(self.lblResult, c)
def startSimlation(self, event):
"Invoked when the user presses the start button"
self.bSimulation.enabled = False
#Instances of javax.swing.SwingWorker are not reusable, so
#we create new instances as needed.
self.simtask = SimulationTask(self)
# self.simtask.addPropertyChangeListener(self)
self.simtask.execute()
def saveConfiguration(self,event):
if self.radioBtnOMC.isSelected() or self.radioBtnDY.isSelected():
self.config= SimulationConfigOMCDY()
self.config.set_starttime(self.txtstart.getText())
self.config.set_stoptime(self.txtstop.getText())
self.config.set_tolerance(self.txttolerance.getText())
self.config.set_intervals(self.txtinterval.getText())
self.config.set_method(self.cbsolver.selectedItem)
self.config.set_outputformat(self.cboutformat.selectedItem)
if self.radioBtnOMC.isSelected():
nomfile= './config/simConfigurationOMC.properties'
if self.radioBtnDY.isSelected():
nomfile= './config/simConfigurationDY.properties'
self.config.save_Properties(nomfile, 'Simulation Configuration')
if self.radioBtnJM.isSelected():
self.config= SimulationConfigJM()
self.config.set_starttime(self.txtstart.getText())
self.config.set_stoptime(self.txtstop.getText())
self.config.set_intervals(self.txtinterval.text)
self.config.set_method(self.cbsolver.selectedItem)
self.config.set_algorithm(self.cbalgorithm.selectedItem)
self.config.set_initialization(self.cbinitialize.selectedItem)
self.config.set_outputformat(self.cboutformat.selectedItem)
nomfile= './config/simConfigurationJM.properties'
self.config.save_Properties(nomfile, 'Simulation Configuration')
self.bSimulation.enabled= 1
def loadConfiguration(self, event):
if self.radioBtnOMC.isSelected() or self.radioBtnDY.isSelected():
self.config= SimulationConfigOMCDY()
self.config.load_Properties('./config/simConfigurationOMC.properties')
self.txtstart.setText(self.config.get_starttime())
self.txtstop.setText(self.config.get_stoptime())
self.txttolerance.setText(self.config.get_tolerance())
self.txtinterval.setText(self.config.get_intervals())
self.cbsolver.selectedItem= self.config.get_method()
self.cboutformat.selectedItem= self.config.get_outputformat()
if self.radioBtnJM.isSelected():
self.config= SimulationConfigJM()
self.config.load_Properties('./config/simConfigurationJM.properties')
self.txtstart.setText(self.config.get_starttime())
self.txtstop.setText(self.config.get_stoptime())
self.txtinterval.setText(self.config.get_intervals())
self.cbsolver.selectedItem= self.config.get_method()
self.cbalgorithm.selectedItem= self.config.get_algorithm()
self.cbinitialize.selectedItem= self.config.get_initialization()
# self.cboutformat.selectedItem= self.config.get_outputformat()
self.bSimulation.enabled= 1
示例12: Demo
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
class Demo(JFrame, Runnable):
def __init__(self):
super(Demo, self).__init__()
self.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)
def onQuit(self, e): System.exit(0)
def onJocl(self, e):
self.clockLabel.setText('running')
self.started = Calendar.getInstance().getTimeInMillis();
#print self.textfield1.getText()
#time.sleep(5)
iters = toInt(self.textfield1.getText())
jocl_smoother(iters)
elapsed = Calendar.getInstance().getTimeInMillis() - self.started;
self.clockLabel.setText( 'JOCL Elapsed: %.2f seconds' % ( float( elapsed ) / 1000.0 ) )
def onJava(self, e):
self.clockLabel.setText('running')
self.started = Calendar.getInstance().getTimeInMillis();
#print self.textfield1.getText()
#time.sleep(5)
iters = toInt(self.textfield1.getText())
java_smoother(iters)
elapsed = Calendar.getInstance().getTimeInMillis() - self.started;
self.clockLabel.setText( 'Java Elapsed: %.2f seconds' % ( float( elapsed ) / 1000.0 ) )
示例13: EditSettingsView
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
#.........这里部分代码省略.........
Method to validate input working directories. If directory does not
exist or if a path to a file is provided instead of a path to a
directory the method returns None.
The second return value is a bool indicating if the value has changed.
'''
if os.path.isdir(working_dir):
return working_dir, True
else:
self.logger.error("{} is not a valid working directory."
" No working directory has been "
"saved".format(working_dir))
return None, False
def validate_all_inputs(self, working_dir, console_fontsize,
edit_area_fontsize, bg_color, font_color):
'''
Wrapper around the input validation methods. Returns a tuple containing
the validated inputs with the last value in the tuple a boolean set to
False if any of the values have been altered during the validation
and True if there have been no changes.
'''
# Collect the results of each validation. In future we might use this
# to provide more detailed error logging on bad user input
validation_results = []
# Validate the working directory input string
working_dir, v = self.validate_working_dir(working_dir)
validation_results.append(v)
# Validate the input fontsizes
con_size, v = self.validate_fontsize(console_fontsize, 'console_style')
validation_results.append(v)
edit_size, v = self.validate_fontsize(edit_area_fontsize,
'edit_area_style')
validation_results.append(v)
# Validate input console colors
bg_color, font_color, v = self.validate_colors(bg_color, font_color)
validation_results.append(v)
return (working_dir, int(con_size), font_color, bg_color,
int(edit_size), all(validation_results))
def save(self, event=None):
'''
Save changes made by user on local settings file.
'''
# Update only the working_dir and the server for now
# TODO: update keystrokes, projects list, etc.
working_dir = self.wd_field.getText()
# Read the fontsize from the textfield
console_fontsize = self.fs_field.getText()
edit_area_fontsize = self.edit_area_fs_field.getText()
# Get the user selected font and background colours
bg_color = self.bg_color_combo.getSelectedItem()
font_color = self.font_color_combo.getSelectedItem()
validated = self.validate_all_inputs(working_dir, console_fontsize,
edit_area_fontsize, bg_color,
font_color)
# The server format is "name: url:port". We only need "name"
server = self.combo.getSelectedItem().split(':')[0]
self.controller.update_config(validated[0], server,
validated[1], validated[2],
validated[3], int(validated[4]))
# If no values have been changed, print that settings have been
# updated without errors
if validated[5]:
self.logger.info("Settings have been successfully updated.")
# On saving settings, update the console and edit area properties
self.controller.refreshConsole()
self.controller.refreshEditArea()
# Close window
self.dispose()
# Refresh the syntax highlighting in a separate thread so it updates
# after everything else has been done.
runSwingLater(self.controller.controller.initHighlighting)
def browse(self, event=None):
'''
Open new dialog for the user to select a path as default working dir.
'''
default_path = self.wd_field.getText()
if not os.path.isdir(default_path):
default_path = os.getcwd()
fileChooser = JFileChooser(default_path)
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
# Fixed showDialog bug using showOpenDialog instead. The former was
# duplicating the last folder name in the path due to a Java bug in
# OSX in the implementation of JFileChooser!
status = fileChooser.showOpenDialog(self)
if status == JFileChooser.APPROVE_OPTION:
self.wd_field.setText(fileChooser.getSelectedFile().toString())
示例14: InfoFrame
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
class InfoFrame(JFrame):
def __init__(self, title=""):
JFrame.__init__(self, title)
self.size = 400,500
self.windowClosing = self.closing
label = JLabel(text="Class Name:")
label.horizontalAlignment = JLabel.RIGHT
tpanel = JPanel(layout = awt.FlowLayout())
self.text = JTextField(20, actionPerformed = self.entered)
btn = JButton("Enter", actionPerformed = self.entered)
tpanel.add(label)
tpanel.add(self.text)
tpanel.add(btn)
bpanel = JPanel()
self.tree = JTree(default_tree())
scrollpane = JScrollPane(self.tree)
scrollpane.setMinimumSize(awt.Dimension(200,200))
scrollpane.setPreferredSize(awt.Dimension(350,400))
bpanel.add(scrollpane)
bag = GridBag(self.contentPane)
bag.addRow(tpanel, fill='HORIZONTAL', weightx=1.0, weighty=0.5)
bag.addRow(bpanel, fill='BOTH', weightx=0.5, weighty=1.0)
def closing(self, event):
self.hide()
self.dispose()
def entered(self, event):
name = self.text.getText()
try:
mod = __import__(name)
components = name.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
except ImportError:
mod = None
self.setupTree("Invalid Class", {})
return None
edict, pdict, mdict = getBeanInfo(mod)
pedict = parseEventDict(edict)
ppdict = parsePropDict(pdict)
pmdict = parseMethDict(mdict)
self.setupTree(mod.__name__, pedict, ppdict, pmdict)
def setupTree(self, top, pedict, ppdict, pmdict):
tree_model = SampleModel(top)
events = tree_model.addNode("Events",["<<Events of the class and its ancestors>>"])
props = tree_model.addNode("Properties",["<<Properties of the class and its ancestors>>"])
meths = tree_model.addNode("Methods",["<<Methods of the class and its ancestors>>"])
for key in pedict.keys():
tree_model.addNode(key, pedict[key], parent=events)
for key in ppdict.keys():
tree_model.addNode(key, ppdict[key], parent=props)
for key in pmdict.keys():
tree_model.addNode(key, pmdict[key], parent=meths)
self.tree.setModel(tree_model)
示例15: BurpExtender
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import getText [as 别名]
#.........这里部分代码省略.........
for cookie in self.cookies:
if cookie.getDomain() in self.originalMsgHost:
self.cookie += cookie.getName() + '=' + cookie.getValue() + '; '
self.textArea.append(cookie.getName() + '=' + cookie.getValue() + '\n')
scrollArea = JScrollPane(self.textArea)
scrollArea.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS)
scrollArea.setPreferredSize(Dimension(400, 200))
self.rightPanel = JPanel()
self.rightPanel.setLayout(BorderLayout(3, 3))
self.rightPanel.add(self.UrlPanelLabel, BorderLayout.NORTH)
self.rightPanel.add(scrollArea, BorderLayout.CENTER)
# Panel for the generate URL list and import URL list buttons
generatePanel = JPanel()
generatePanel.layout = BorderLayout(3, 3)
generateButton = JButton('Generate URL List', actionPerformed=self.generateUrlList)
importButton = JButton('Import URL List to Burp Site Map', actionPerformed=self.confirmImport)
generatePanel.add("North", generateButton)
generatePanel.add("South", importButton)
self.rightPanel.add("South", generatePanel)
# Add the two main panels to the left and right sides
self.window.contentPane.add("East", self.rightPanel)
self.window.contentPane.add("West", self.leftPanel)
# Create a panel to be used for the file chooser window
self.uploadPanel = JPanel()
self.window.pack()
self.window.show()
# JFileChooser and showDialog for the user to specify their directory listing input file
def chooseFile(self, event):
chooseFile = JFileChooser()
filter = FileNameExtensionFilter("c files", ["c"])
chooseFile.addChoosableFileFilter(filter)
chooseFile.showDialog(self.uploadPanel, "Choose File")
chosenFile = chooseFile.getSelectedFile()
self.uploadTextField.text = str(chosenFile)
# Set whether https is enabled. Default is disabled (http)
def radioSsl(self, event):
if self.radioBtnSslEnabled.isSelected():
self.SSL = 'https://'
else:
self.SSL = 'http://'
# Create a parser object and pass the user's specified options. Retrieve the results and print them to a text area
def generateUrlList(self, event):
fileListingType = self.comboListingType.selectedIndex
self.listType = self.types[fileListingType]
urlsMade = 0
if os.path.isfile(self.uploadTextField.text):
parser = ListingParser()
parser.parse(self.hostnameTextField.getText(), self.dirPrefixField.getText().rstrip(), self.SSL, self.portTextField.getText(), self.listType, self.uploadTextField.getText())
self.parsedList = parser.returnList()
self.textArea.setText('')
for item in self.parsedList:
self.textArea.append(item + '\n')
urlsMade = str(len(self.parsedList))
if self.parsedList and urlsMade:
self.textArea.append('\n' + 'Total Directories Found: ' + str(parser.directoryCount))
self.textArea.append('\n' + 'Total URLs Created: ' + urlsMade)
else:
self.textArea.append('Error occurred during parsing.\n')
self.textArea.append('Please make sure the directory listing is a valid format and all input is correct.\n')
self.textArea.append('E-mail [email protected] with errors or for further help.')
else:
JOptionPane.showMessageDialog(None, 'ERROR: File is not valid file or not found!')
def closeUI(self, event):
self.window.setVisible(False)
self.window.dispose()
# This is initiated by the user selecting the 'import to burp' button. Checks each generated URL for a valid response and adds it to the site map
def importList(self):
if self.parsedList:
urlsAdded = 0
# Loop through each URL and check the response. If the response code is less than 404, add to site map
for item in self.parsedList:
# Pass exception if urlopen returns an http error if the URL is not reachable
try:
code = urlopen(item).code
if code < 404:
javaURL = URL(item)
newRequest = self._helpers.buildHttpRequest(javaURL)
stringNewRequest = self._helpers.bytesToString(newRequest).rstrip()
if self.cookie:
stringNewRequest += '\nCookie: ' + self.cookie.rstrip('; ') + '\r\n\r\n'
requestResponse = self._callbacks.makeHttpRequest(self._helpers.buildHttpService(str(javaURL.getHost()), int(javaURL.getPort()), javaURL.getProtocol() == "https"), stringNewRequest)
else:
requestResponse = self._callbacks.makeHttpRequest(self._helpers.buildHttpService(str(javaURL.getHost()), int(javaURL.getPort()), javaURL.getProtocol() == "https"), newRequest)
self._callbacks.addToSiteMap(requestResponse)
urlsAdded += 1
except Exception, e:
print e
pass
JOptionPane.showMessageDialog(None, str(urlsAdded) + " URL(s) added to Burp site map.")
else:
开发者ID:LucaBongiorni,项目名称:Directory-File-Listing-Parser-Importer,代码行数:104,代码来源:Directory-File-Listing-Parser-Importer.py