本文整理汇总了Python中javax.swing.JTextField.requestFocusInWindow方法的典型用法代码示例。如果您正苦于以下问题:Python JTextField.requestFocusInWindow方法的具体用法?Python JTextField.requestFocusInWindow怎么用?Python JTextField.requestFocusInWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextField
的用法示例。
在下文中一共展示了JTextField.requestFocusInWindow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BurpExtender
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import requestFocusInWindow [as 别名]
class BurpExtender(IBurpExtender, ITab, IScannerCheck, IContextMenuFactory, IParameter, IIntruderPayloadGeneratorFactory):
def registerExtenderCallbacks(self, callbacks):
self.callbacks = callbacks
self.helpers = callbacks.getHelpers()
callbacks.setExtensionName("Session Authentication Tool")
self.out = callbacks.getStdout()
# definition of suite tab
self.tab = JPanel(GridBagLayout())
self.tabledata = MappingTableModel(callbacks)
self.table = JTable(self.tabledata)
#self.table.getColumnModel().getColumn(0).setPreferredWidth(50);
#self.table.getColumnModel().getColumn(1).setPreferredWidth(100);
self.tablecont = JScrollPane(self.table)
c = GridBagConstraints()
c.fill = GridBagConstraints.HORIZONTAL
c.anchor = GridBagConstraints.FIRST_LINE_START
c.gridx = 0
c.gridy = 0
c.gridheight = 6
c.weightx = 0.3
c.weighty = 0.5
self.tab.add(self.tablecont, c)
c = GridBagConstraints()
c.weightx = 0.1
c.anchor = GridBagConstraints.FIRST_LINE_START
c.gridx = 1
c.gridy = 0
label_id = JLabel("Identifier:")
self.tab.add(label_id, c)
self.input_id = JTextField(20)
self.input_id.setToolTipText("Enter the identifier which is used by the application to identifiy a particular test user account, e.g. a numerical user id or a user name.")
c.gridy = 1
self.tab.add(self.input_id, c)
c.gridy = 2
label_content = JLabel("Content:")
self.tab.add(label_content, c)
self.input_content = JTextField(20, actionPerformed=self.btn_add_id)
self.input_content.setToolTipText("Enter some content which is displayed in responses of the application and shows that the current session belongs to a particular user, e.g. the full name of the user.")
c.gridy = 3
self.tab.add(self.input_content, c)
self.btn_add = JButton("Add/Edit Identity", actionPerformed=self.btn_add_id)
c.gridy = 4
self.tab.add(self.btn_add, c)
self.btn_del = JButton("Delete Identity", actionPerformed=self.btn_del_id)
c.gridy = 5
self.tab.add(self.btn_del, c)
callbacks.customizeUiComponent(self.tab)
callbacks.customizeUiComponent(self.table)
callbacks.customizeUiComponent(self.tablecont)
callbacks.customizeUiComponent(self.btn_add)
callbacks.customizeUiComponent(self.btn_del)
callbacks.customizeUiComponent(label_id)
callbacks.customizeUiComponent(self.input_id)
callbacks.addSuiteTab(self)
callbacks.registerScannerCheck(self)
callbacks.registerIntruderPayloadGeneratorFactory(self)
callbacks.registerContextMenuFactory(self)
def btn_add_id(self, e):
ident = self.input_id.text
self.input_id.text = ""
content = self.input_content.text
self.input_content.text = ""
self.tabledata.add_mapping(ident, content)
self.input_id.requestFocusInWindow()
def btn_del_id(self, e):
rows = self.table.getSelectedRows().tolist()
self.tabledata.del_rows(rows)
### ITab ###
def getTabCaption(self):
return("SessionAuth")
def getUiComponent(self):
return self.tab
### IContextMenuFactory ###
def createMenuItems(self, invocation):
menuitems = list()
msgs = invocation.getSelectedMessages()
if msgs != None:
if len(msgs) == 1: # "add as object id/as content to last id" context menu items
bounds = invocation.getSelectionBounds()
if bounds != None and bounds[0] != bounds[1]:
msg = None
if invocation.getInvocationContext() == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST or invocation.getInvocationContext() == IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_REQUEST:
msg = msgs[0].getRequest().tostring()
if invocation.getInvocationContext() == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_RESPONSE or invocation.getInvocationContext() == IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_RESPONSE:
msg = msgs[0].getResponse().tostring()
if msg != None:
selection = msg[bounds[0]:bounds[1]]
shortSelection = selection[:20]
#.........这里部分代码省略.........
示例2: ChatApp
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import requestFocusInWindow [as 别名]
#.........这里部分代码省略.........
quit_btn=JButton(" Quit! ", actionPerformed=self.closeEvent, border=self.border2, font=self.btn_font)
go_btn=JButton(" Go! ", actionPerformed=self.continueEvent, border=self.border2, font=self.btn_font)
# Colours
quit_btn.setBackground(background_colour)
go_btn.setBackground(background_colour)
quit_btn.setForeground(foreground_colour)
go_btn.setForeground(foreground_colour)
# Setting up the horizontal groups parameters
layout.setHorizontalGroup(layout.createSequentialGroup()
# Left side
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(user_label)
.addComponent(server_label))
# Right side
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(self.username)
.addComponent(self.server)
.addGroup(layout.createSequentialGroup()
.addComponent(quit_btn)
.addComponent(go_btn)))
)
# Setting up Vertical Groups
layout.setVerticalGroup(layout.createSequentialGroup()
# Top group
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(user_label)
.addComponent(self.username))
# Middle group
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(server_label)
.addComponent(self.server))
# Bottom group
.addGroup(layout.createParallelGroup()
.addComponent(quit_btn)
.addComponent(go_btn))
)
# Finalise the GUI
layout.linkSize(SwingConstants.HORIZONTAL, [quit_btn,go_btn])
self.getContentPane().setBackground(window_background)
self.pack()
self.setTitle('Chat Login')
self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
self.setLocationRelativeTo(None)
self.setVisible(True)
## Event driven funtion to respond to quit button click
def closeEvent(self,event):
'''Function to close the login window
'''
print("Goodbye!")
exit()
## Event driven function to respond to send button click, grabs text and sends it down the wire
def continueEvent(self,event):
'''Function that retreives the login details for sending to the server
'''
# Grab the text that has been entered
user = self.username.getText()
Host = self.server.getText()
# Default port
Port=60001
connected=False
while not connected:
# Try make a connection except when there isn't one available, then quit program'
try:
tn=telnetlib.Telnet(Host, Port)
connected=True
continue
except:
JOptionPane.showMessageDialog(self,'Connection Error, No Server Available!')
self.username.setText('')
self.server.setText('')
self.username.requestFocusInWindow()
return
# Listen for a response
response = tn.read_until('<<<')
print(response)
# Acknowledge with the username
tn.write(user+'\r\n')
# Receive validation of name, present dialog if not valid
valid_name = tn.read_until('<')
valid_name.strip()
v_name, delim = valid_name.split('<')
if v_name.strip() != 'OK':
JOptionPane.showMessageDialog(self,'Bad Username, please choose another')
self.username.setText('')
self.username.requestFocusInWindow()
return
# Set the login GUI to hidden
self.setVisible(False) ## <<<<<< I have no idea why this doesn't work but I suspect it's something to do with either inheritance or having 2 class instances
# Call the main program, pass the connection as a parameter
ChatClient(user,response , tn)