本文整理汇总了Python中javax.swing.JTextArea.setFont方法的典型用法代码示例。如果您正苦于以下问题:Python JTextArea.setFont方法的具体用法?Python JTextArea.setFont怎么用?Python JTextArea.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.setFont方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BurpExtender
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setFont [as 别名]
class BurpExtender(IBurpExtender, IContextMenuFactory):
# Implement IBurpExtender
def registerExtenderCallbacks(self, callbacks):
self.printHeader()
# Set extension name
callbacks.setExtensionName("Directory Listing Parser for Burp Suite")
# Callbacks object
self._callbacks = callbacks
# Helpers object
self._helpers = callbacks.getHelpers()
# Register a factory for custom context menu items
callbacks.registerContextMenuFactory(self)
return
# Create a menu item if the appropriate section of the UI is selected
def createMenuItems(self, invocation):
menu = []
# Which part of the interface the user selects
ctx = invocation.getInvocationContext()
# Message Viewer Req/Res, Site Map Table, and Proxy History will show menu item if selected by the user
if ctx == 2 or ctx == 3 or ctx == 4 or ctx == 5 or ctx == 6:
menu.append(JMenuItem("Import Directory Listing", None, actionPerformed=lambda x, inv=invocation: self.openGUI(inv)))
return menu if menu else None
# Create and place GUI components on JFrame
def openGUI(self, invocation):
try:
# Get values from request or response the extension is invoked from and prepopulate GUI values
invMessage = invocation.getSelectedMessages()
message = invMessage[0]
originalHttpService = message.getHttpService()
self.originalMsgProtocol = originalHttpService.getProtocol()
self.originalMsgHost = originalHttpService.getHost()
self.originalMsgPort = originalHttpService.getPort()
except:
self.originalMsgProtocol = ''
self.originalMsgHost = ''
self.originalMsgPort = ''
try:
self.cookies = self._callbacks.getCookieJarContents()
self.cookie = ''
except:
pass
self.SSL = 'http://'
self.listType = ''
self.parsedList = []
# Set up main window (JFrame)
self.window = JFrame("Directory Listing Parser for Burp Suite", preferredSize=(600, 475), windowClosing=self.closeUI)
self.window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE)
emptyBorder = BorderFactory.createEmptyBorder(10, 10, 10, 10)
self.window.contentPane.setBorder(emptyBorder)
self.window.contentPane.layout = BorderLayout()
# Main window title placed at the top of the main window with an invisible bottom border
titlePanel = JPanel()
titleBorder = BorderFactory.createEmptyBorder(0, 0, 10, 0)
title = JLabel("Directory Listing Parser for Burp Suite", JLabel.CENTER)
title.setBorder(titleBorder)
title.setFont(Font("Default", Font.PLAIN, 18))
titlePanel.add(title)
self.window.contentPane.add("North", titlePanel)
# Left panel for user input, consisting of hostname, directory prefix, ssl, port, type of listing, and file
self.leftPanel = JPanel()
self.leftPanel.layout = GridLayout(14, 1, 3, 3)
hostnameLabel = JLabel("Hostname:")
if self.originalMsgHost:
self.hostnameTextField = JTextField(self.originalMsgHost.rstrip())
else:
self.hostnameTextField = JTextField('Hostname')
dirPrefixLabel = JLabel("Full Directory Prefix (Windows):")
self.dirPrefixField = JTextField('C:\\var\www\\')
sslLabel = JLabel("SSL:")
self.radioBtnSslEnabled = JRadioButton('Enabled (https)', actionPerformed=self.radioSsl)
self.radioBtnSslDisabled = JRadioButton('Disabled (http)', actionPerformed=self.radioSsl)
sslButtonGroup = ButtonGroup()
sslButtonGroup.add(self.radioBtnSslEnabled)
sslButtonGroup.add(self.radioBtnSslDisabled)
if self.originalMsgProtocol == "https":
self.radioBtnSslEnabled.setSelected(True)
else:
self.radioBtnSslDisabled.setSelected(True)
portLabel = JLabel("Port:")
#.........这里部分代码省略.........
开发者ID:LucaBongiorni,项目名称:Directory-File-Listing-Parser-Importer,代码行数:103,代码来源:Directory-File-Listing-Parser-Importer.py
示例2: HandRecoWriter
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setFont [as 别名]
#.........这里部分代码省略.........
word_classifier_file.close()
#Set up window
self.setTitle("HandReco Writer")
self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
self.setLocationRelativeTo(None)
self.setLayout(BorderLayout())
#Set up menu
menu_bar = JMenuBar()
info_menu = JMenu("Info")
def instructions(event):
instr = '''
The program can just recognise capital English characters.
See Info -> Available Words... for available word corrections.
Good Luck with the writing!'''
JOptionPane.showMessageDialog(self, instr,
"Instructions",
JOptionPane.INFORMATION_MESSAGE)
instructions_menu_item = JMenuItem("Instructions...",actionPerformed=instructions)
info_menu.add(instructions_menu_item)
def word_corrections(event):
words_string = ""
for word in self.word_classifier.words:
words_string = words_string + word.upper() + "\n"
text = "The words that can be corrected are:\n\n" +words_string
dialog = JOptionPane(text,
JOptionPane.INFORMATION_MESSAGE)
dialog_wrapper = JDialog(self,"Available Words",False)
dialog_wrapper.setContentPane(dialog)
dialog_wrapper.pack()
dialog_wrapper.setVisible(True)
word_corrections_menu_item = JMenuItem("Available Words...",actionPerformed=word_corrections)
info_menu.add(word_corrections_menu_item)
menu_bar.add(info_menu)
self.setJMenuBar(menu_bar)
#Input panel
input_panel = JPanel()
input_panel.setLayout(BoxLayout(input_panel, BoxLayout.X_AXIS))
input_panel.setBorder(BorderFactory.createTitledBorder("Input"))
self.paint_area = PaintArea(100,100)
input_panel.add(self.paint_area)
input_options_panel = JPanel()
input_options_panel.setLayout(BoxLayout(input_options_panel, BoxLayout.Y_AXIS))
#Write Char
write_char_panel = JPanel(BorderLayout())
def write_char(event):
char = self.character_classifier.classify_image(self.paint_area.image())
self.text_area.setText(self.text_area.getText() + char)
self.paint_area.clear()
write_char_panel.add(JButton("Write Char", actionPerformed=write_char), BorderLayout.NORTH)
input_options_panel.add(write_char_panel)
#Space and Correct
space_and_correct_panel = JPanel(BorderLayout())
def space_and_correct(event):
text = self.text_area.getText()
words = text.split(" ")
string = words[-1]
try:
word = self.word_classifier.classify(string.lower())
words[-1] = word.upper()
except:
JOptionPane.showMessageDialog(self, "Have you entered a character which is not in the alphabet?",
"Could not Correct",
JOptionPane.ERROR_MESSAGE)
self.text_area.setText(text + " ")
return
newText = ""
for w in words:
newText = newText + w + " "
self.text_area.setText(newText)
space_and_correct_panel.add(JButton("Space and Correct", actionPerformed=space_and_correct), BorderLayout.NORTH)
input_options_panel.add(space_and_correct_panel)
#Space
space_panel = JPanel(BorderLayout())
def space(event):
self.text_area.setText(self.text_area.getText() + " ")
space_panel.add(JButton("Space", actionPerformed=space), BorderLayout.NORTH)
input_options_panel.add(space_panel)
#Clear Input Area
clear_input_area_panel = JPanel(BorderLayout())
def clear(event):
self.paint_area.clear()
clear_input_area_panel.add(JButton("Clear Input Area", actionPerformed=clear), BorderLayout.NORTH)
input_options_panel.add(clear_input_area_panel)
input_panel.add(input_options_panel)
self.add(input_panel, BorderLayout.NORTH)
text_area_panel = JPanel()
text_area_panel.setLayout(BorderLayout())
text_area_panel.setBorder(BorderFactory.createTitledBorder("Text"))
self.text_area = JTextArea()
self.text_area.setLineWrap(True)
#Increase font size
font = self.text_area.getFont()
self.text_area.setFont(Font(font.getName(), Font.BOLD, 24))
text_area_panel.add(JScrollPane(self.text_area), BorderLayout.CENTER)
self.add(text_area_panel, BorderLayout.CENTER)
self.pack()
self.setSize(Dimension(300,300))
self.setVisible(True)
示例3: ConsolePanel
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setFont [as 别名]
class ConsolePanel(Panel):
def __init__(self):
self.console = None
self.outText = None
self.inText = None
self.outTextScroller = None
self.nestedInputPanel = None
self.directoryText = None
Panel.__init__(self, "insets 0 0 0 0")
def sendCommand(self, command):
print str(self)
oldText = self.inText.getText()
self.inText.setText(command)
self.inText.getActionListeners()[0].actionPerformed(None)
self.inText.setText(oldText)
def setDirectoryText(self, dirText):
self.directoryText.setText(dirText)
self.nestedInputPanel.revalidate()
def write_out(self,text):
if not self.outText:
return
self.outText.setText(self.outText.getText() + text)
def initUI(self):
font = Font("Courier New", Font.BOLD, 14)
#create the output text panel
self.outText = JTextArea()
self.outText.setEditable(False)
self.outText.setFont(font)
self.outText.setWrapStyleWord(True)
self.outText.setLineWrap(True)
#self.outText.setLineWrap(True)
#self.outText.setWrapStyleWord(True)
class NoGhostScroller(JScrollPane):
def paintComponent(self, g):
g.setColor(self.getBackground())
g.fillRect(0, 0, self.getWidth(), self.getHeight())
#super(NoGhostScroller, self).paintComponent(g)
self.outTextScroller = JScrollPane(self.outText)
self.outTextScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)
self.outTextScroller.getVerticalScrollBar().setForeground(Color(255, 0, 0))
#self.outText.setOpaque(False)
self.outText.setBackground(Color(0, 20, 0))
self.outText.setForeground(Color.WHITE)
#self.outTextScroller.setOpaque(False)
self.outTextScroller.setBackground(Color(0, 20, 0))
#self.outText.repaint()
#self.layered = JLayeredPane()
#self.layered.setLayer(self.outTextScroller, 0)
#create the input text box
self.inText = JTextField()
self.inText.setFocusTraversalKeysEnabled(False)
self.inText.setFont(font)
self.inText.setBackground(Color(0, 20, 0))
self.inText.setForeground(Color.WHITE)
self.inText.getCaret().setVisible(True)
self.inText.getCaret().setBlinkRate(500)
self.inText.setCaretColor(Color(200,255,200))
class InFocusAdapter(FocusAdapter):
def focusLost(adap, e):
self.inText.setVisible(True)
self.inText.addFocusListener(InFocusAdapter())
self.nestedInputPanel = Panel("Insets 0 0 0 0")
#create the directory text box
self.directoryText = JTextField()
self.directoryText.setEditable(False)
self.directoryText.setFont(font)
self.directoryText.setBackground(Color(0, 20, 0))
self.directoryText.setForeground(Color.WHITE)
#set up the console
sys.stdout = FakeOut(self.outText)
self.console = BashED_Console(stdout=sys.stdout)
self.directoryText.setText(self.console.get_prompt())
self.revalidate();
dirTex = self.directoryText;
#create the listener that fires when the 'return' key is pressed
class InputTextActionListener(ActionListener):
def __init__(self,parent,inp,out,console):
self.parent = parent
self.inp = inp
#.........这里部分代码省略.........