本文整理汇总了Python中javax.swing.JScrollPane.setViewportView方法的典型用法代码示例。如果您正苦于以下问题:Python JScrollPane.setViewportView方法的具体用法?Python JScrollPane.setViewportView怎么用?Python JScrollPane.setViewportView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JScrollPane
的用法示例。
在下文中一共展示了JScrollPane.setViewportView方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConsoleTab
# 需要导入模块: from javax.swing import JScrollPane [as 别名]
# 或者: from javax.swing.JScrollPane import setViewportView [as 别名]
class ConsoleTab(ITab):
def __init__(self, burp):
self.burp = burp
self.log = burp.log
self.config = burp.config
self.caption = burp.loadExtensionSetting(*settings.CONSOLE_CAPTION)
self.scrollpane = JScrollPane()
self.console = Console(burp)
self.scrollpane.setViewportView(self.console.textpane)
self.burp.addSuiteTab(self)
self.burp.customizeUiComponent(self.getUiComponent())
def getUiComponent(self):
return self.scrollpane
def getTabCaption(self):
return self.caption
@property
def interpreter(self):
return self.console.interp
示例2: BurpExtender
# 需要导入模块: from javax.swing import JScrollPane [as 别名]
# 或者: from javax.swing.JScrollPane import setViewportView [as 别名]
class BurpExtender(IBurpExtender, IExtensionStateListener, IHttpListener, IProxyListener, ITab):
def registerExtenderCallbacks(self, callbacks):
self.callbacks = callbacks
self.helpers = callbacks.helpers
self.scriptpane = JTextPane()
self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11))
self.scrollpane = JScrollPane()
self.scrollpane.setViewportView(self.scriptpane)
self._code = compile('', '<string>', 'exec')
self._script = ''
callbacks.registerExtensionStateListener(self)
callbacks.registerProxyListener(self)
callbacks.customizeUiComponent(self.getUiComponent())
callbacks.addSuiteTab(self)
self.scriptpane.requestFocus()
def extensionUnloaded(self):
try:
self.callbacks.saveExtensionSetting(
'script', base64.b64encode(self._script))
except Exception:
traceback.print_exc(file=self.callbacks.getStderr())
return
def processProxyMessage(self, messageIsRequest, message):
try:
globals_ = {'extender': self,
'callbacks': self.callbacks,
'helpers': self.helpers
}
locals_ = {'messageIsRequest': messageIsRequest,
'message': message
}
exec(self.script, globals_, locals_)
except Exception:
traceback.print_exc(file=self.callbacks.getStderr())
return
def getTabCaption(self):
return 'Script'
def getUiComponent(self):
return self.scrollpane
@property
def script(self):
end = self.scriptpane.document.length
_script = self.scriptpane.document.getText(0, end)
if _script == self._script:
return self._code
self._script = _script
self._code = compile(_script, '<string>', 'exec')
return self._code
示例3: BurpExtender
# 需要导入模块: from javax.swing import JScrollPane [as 别名]
# 或者: from javax.swing.JScrollPane import setViewportView [as 别名]
class BurpExtender(IBurpExtender, IContextMenuFactory, ITab):
def registerExtenderCallbacks(self, callbacks):
self.callbacks = callbacks
self.helpers = callbacks.helpers
self.console = Console(self, namespace={
'callbacks': callbacks,
'helpers': callbacks.helpers,
})
self.scrollpane = JScrollPane()
self.scrollpane.setViewportView(self.console.textpane)
callbacks.setExtensionName("Jython Console")
callbacks.addSuiteTab(self)
callbacks.registerContextMenuFactory(self)
callbacks.customizeUiComponent(self.getUiComponent())
def getUiComponent(self):
return self.scrollpane
def getTabCaption(self):
return "Console"
def createMenuItems(self, invocation):
menus = []
messages = invocation.getSelectedMessages()
if messages:
items = self.interpreter.getLocals().get('items', [])
context = 'Assign' if not items else 'Append'
menu = JMenuItem("%s to local variable items in Console" % (context, ))
menu.addActionListener(AssignLocalsActionListener(self, 'items', messages))
menus.append(menu)
return menus
@property
def interpreter(self):
return self.console.interp
示例4: _initializeGui
# 需要导入模块: from javax.swing import JScrollPane [as 别名]
# 或者: from javax.swing.JScrollPane import setViewportView [as 别名]
def _initializeGui(self, callbacks):
tab = JPanel()
jLabel1 = JLabel("Original Hash:")
jLabel2 = JLabel("Original message:")
jLabel3 = JLabel("Message to append:")
jLabel5 = JLabel("Max key length:")
jTextField1 = JTextField("")
jTextField2 = JTextField("")
jTextField3 = JTextField("")
jTextField4 = JTextField("128")
jLabel4 = JLabel("Hashing functions")
jCheckBox1 = JCheckBox("MD4")
jCheckBox2 = JCheckBox("MD5")
jCheckBox3 = JCheckBox("SHA1")
jCheckBox4 = JCheckBox("SHA256")
jCheckBox5 = JCheckBox("SHA512")
jCheckBox1.setEnabled(False)
jCheckBox2.setEnabled(False)
jCheckBox3.setEnabled(False)
jCheckBox4.setEnabled(False)
jCheckBox5.setEnabled(False)
jScrollPane1 = JScrollPane()
jTable1 = JTable()
jButton1 = JButton("Generate", actionPerformed=self.generate_attack)
jButton1.setEnabled(False)
jButton2 = JButton("Copy messages", actionPerformed=self.copy_messages)
jButton3 = JButton("Copy hashes", actionPerformed=self.copy_hashes)
self._tab = tab
self._textfields = {
"original_hash": jTextField1,
"original_msg": jTextField2,
"append_msg": jTextField3,
"max_key_len": jTextField4,
}
self._checkboxes = {
md4: jCheckBox1,
md5: jCheckBox2,
sha1: jCheckBox3,
sha256: jCheckBox4,
sha512: jCheckBox5,
}
self._table = jTable1
self._extensions = {}
self._hashes, self._messages = [], []
# Hash field change event
jTextField1.getDocument().addDocumentListener(HashChangeListener(self._checkboxes, self._textfields['original_hash'], jButton1))
# Table columns
jTable1.setModel(DefaultTableModel([],["#", "Type","New Message", "Hash"]))
jScrollPane1.setViewportView(jTable1)
# Table column width
jTable1.getColumnModel().getColumn(0).setMaxWidth(50)
jTable1.getColumnModel().getColumn(1).setMaxWidth(60)
layout = GroupLayout(tab)
tab.setLayout(layout)
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(jTextField3, GroupLayout.DEFAULT_SIZE, 425, 32767)
.addComponent(jTextField2)
.addComponent(jTextField1)
.addGroup(layout.createSequentialGroup()
.addComponent(jTextField4, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 32767)))
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox1)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCheckBox2)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCheckBox3)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCheckBox4)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCheckBox5))
.addComponent(jLabel4)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)))
.addGap(167, 167, 167))
.addComponent(jScrollPane1)
)
#.........这里部分代码省略.........
示例5: BurpExtender
# 需要导入模块: from javax.swing import JScrollPane [as 别名]
# 或者: from javax.swing.JScrollPane import setViewportView [as 别名]
class BurpExtender(IBurpExtender, IExtensionStateListener, IHttpListener, ITab):
def registerExtenderCallbacks(self, callbacks):
self.callbacks = callbacks
self.helpers = callbacks.helpers
# text pane
self.scriptpane = JTextPane()
self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11))
self.scrollpane = JScrollPane()
self.scrollpane.setViewportView(self.scriptpane)
# compile to bytecode
self._code = compile('', '<string>', 'exec')
self._script = ''
# load configuration settings for the extension that were saved using the method saveExtensionSetting().
script = callbacks.loadExtensionSetting('script')
if script:
script = base64.b64decode(script)
self.scriptpane.document.insertString(
self.scriptpane.document.length,
script,
SimpleAttributeSet())
self._script = script
self._code = compile(script, '<string>', 'exec')
# register
callbacks.registerExtensionStateListener(self)
callbacks.registerHttpListener(self)
# ui
callbacks.customizeUiComponent(self.getUiComponent())
callbacks.addSuiteTab(self)
self.scriptpane.requestFocus()
#
# extender unload
#
def extensionUnloaded(self):
try:
# save script, base64 encode
self.callbacks.saveExtensionSetting(
'script', base64.b64encode(self._script))
except Exception:
traceback.print_exc(file=self.callbacks.getStderr())
return
#
# implement IHttpListener
#
def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo):
try:
globals_ = {'extender': self,
'callbacks': self.callbacks,
'helpers': self.helpers
}
locals_ = {'toolFlag': toolFlag,
'messageIsRequest': messageIsRequest,
'messageInfo': messageInfo
}
exec(self.script, globals_, locals_)
except Exception:
traceback.print_exc(file=self.callbacks.getStderr())
return
#
# implement ITab
#
def getTabCaption(self):
return 'Script'
def getUiComponent(self):
return self.scrollpane
#
# script 不变时,不用重复编译, 优化性能
#
@property
def script(self):
end = self.scriptpane.document.length
_script = self.scriptpane.document.getText(0, end)
if _script == self._script:
return self._code
self._script = _script
self._code = compile(_script, '<string>', 'exec')
return self._code
示例6: ChatClient
# 需要导入模块: from javax.swing import JScrollPane [as 别名]
# 或者: from javax.swing.JScrollPane import setViewportView [as 别名]
class ChatClient(JFrame):
## Constructor method, receives the variables from the ChatApp class as parameters
def __init__(self, name, greeting, tn):
'''Constructor, initialises base class & assigns variables
'''
# Call to the super method to take care of the base class(es)
super(ChatClient, self).__init__()
# Assign the relevent variable names
self.username=name
self.greeting=greeting
self.tn = tn
self.no_users=[]
# Initiate the Threaded function for receiving messages
t1=Thread(target=self.recvFunction)
# Set to daemon
t1.daemon=True
t1.start()
#Call the main UI
uI=self.clientUI()
## Main GUI building function
def clientUI(self):
'''ClientUI and Widget creation
'''
# Colours
foreground_colour = Color(30,57,68)
background_colour = Color(247,246,242)
window_background = Color(145,190,210)
# Borders
self.border2=BorderFactory.createLineBorder(foreground_colour,1, True)
# Fonts
self.font= Font("Ubuntu Light", Font.BOLD, 20)
self.label_font= Font("Ubuntu Light", Font.BOLD, 17)
self.label_2_font= Font( "Ubuntu Light",Font.BOLD, 12)
self.btn_font=Font("Ubuntu Light", Font.BOLD, 15)
# Set the layout parameters
self.client_layout=GroupLayout(self.getContentPane())
self.getContentPane().setLayout(self.client_layout)
self.getContentPane().setBackground(window_background)
self.client_layout.setAutoCreateGaps(True)
self.client_layout.setAutoCreateContainerGaps(True)
self.setPreferredSize(Dimension(400, 450))
# Create widgets and assemble the GUI
# Main display area
self.main_content=JTextPane()
self.main_content.setBackground(background_colour)
#self.main_content.setForeground(foreground_colour)
self.main_content.setEditable(False)
# Message entry area
self.message=JTextArea( 2,2, border=self.border2, font=self.label_font, keyPressed=self.returnKeyPress)
self.message.requestFocusInWindow()
self.message.setBackground(background_colour)
self.message.setForeground(foreground_colour)
self.message.setLineWrap(True)
self.message.setWrapStyleWord(True)
self.message.setBorder(BorderFactory.createEmptyBorder(3,3,3,3))
self.message.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), self.returnKeyPress)
# BUttons
quit_btn=JButton("Quit!", actionPerformed=ChatApp().closeEvent, border=self.border2, font=self.btn_font)
go_btn=JButton("Send", actionPerformed=self.grabText, border=self.border2, font=self.btn_font)
quit_btn.setBackground(background_colour)
go_btn.setBackground(background_colour)
quit_btn.setForeground(foreground_colour)
go_btn.setForeground(foreground_colour)
# Make scrollable
self.scroll_content=JScrollPane(self.main_content)
self.scroll_content.setPreferredSize(Dimension(150,275))
self.scroll_content.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)
self.scroll_content.setViewportView(self.main_content)
self.scroll_content.setBackground(Color.WHITE)
self.scroll_message=JScrollPane(self.message)
self.scroll_message.setPreferredSize(Dimension(150,20))
self.scroll_message.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS)
# Test user label, still not updating after first round of messages
self.user_label=JLabel(" Users online : %s "%(str(len(self.no_users))),JLabel.RIGHT, font=self.label_2_font)
# Assemble the components
# Horizontal layout
self.client_layout.setHorizontalGroup(self.client_layout.createParallelGroup()
.addComponent(self.scroll_content)
.addGroup(self.client_layout.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(self.scroll_message))
.addGroup(self.client_layout.createSequentialGroup()
.addComponent(quit_btn)
.addComponent(go_btn).addGap(20))
.addGroup(self.client_layout.createParallelGroup()
.addComponent(self.user_label))
)
# Vertical layout
self.client_layout.setVerticalGroup(self.client_layout.createSequentialGroup()
.addGroup(self.client_layout.createParallelGroup()
.addComponent(self.scroll_content))
#.........这里部分代码省略.........
示例7: BurpExtender
# 需要导入模块: from javax.swing import JScrollPane [as 别名]
# 或者: from javax.swing.JScrollPane import setViewportView [as 别名]
class BurpExtender(IBurpExtender, IIntruderPayloadGeneratorFactory, IExtensionStateListener, ITab):
#
# implement IBurpExtender
#
def registerExtenderCallbacks(self, callbacks):
callbacks.registerExtensionStateListener(self)
# keep a reference to our callbacks object
self._callbacks = callbacks
# obtain an extension helpers object
self._helpers = callbacks.getHelpers()
# set our extension name
callbacks.setExtensionName("Super Payload")
# register ourselves as a payload generator factory
callbacks.registerIntruderPayloadGeneratorFactory(self)
# the Super Payload UI
self.scriptpane = JTextPane()
self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11))
self.scrollpane = JScrollPane()
self.scrollpane.setViewportView(self.scriptpane)
callbacks.customizeUiComponent(self.getUiComponent())
callbacks.addSuiteTab(self)
self.scriptpane.requestFocus()
# Compile the init script content
self._code = compile('', '<string>', 'exec')
self._script = ''
script = callbacks.loadExtensionSetting('script')
if script:
script = base64.b64decode(script)
self.scriptpane.document.insertString(
self.scriptpane.document.length,
script,
SimpleAttributeSet())
self._script = script
self._code = compile(script, '<string>', 'exec')
return
def createNewInstance(self, attack):
return SuperGenerator(self, attack)
def getGeneratorName(self):
return "SuperPayload"
def extensionUnloaded(self):
try:
self.callbacks.saveExtensionSetting(
'script', base64.b64encode(self._script))
except Exception:
traceback.print_exc(file=self.callbacks.getStderr())
return
def getTabCaption(self):
return 'Super Payload Script'
def getUiComponent(self):
return self.scrollpane
# Get the compiled code of user script (update or not)
@property
def script(self):
end = self.scriptpane.document.length
_script = self.scriptpane.document.getText(0, end)
if _script == self._script:
return self._code
self._script = _script
self._code = compile(_script, '<string>', 'exec')
return self._code