本文整理汇总了Python中javax.swing.JTextArea.setWrapStyleWord方法的典型用法代码示例。如果您正苦于以下问题:Python JTextArea.setWrapStyleWord方法的具体用法?Python JTextArea.setWrapStyleWord怎么用?Python JTextArea.setWrapStyleWord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.setWrapStyleWord方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initGUI
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [as 别名]
def initGUI(self):
#Set up subpanel1
appName = JTextArea('Politeness Gauge\n'+'\nSarah Robinson \nAnna Clegg')
appName.setLineWrap(True)
appName.setWrapStyleWord(True)
appName.setEditable(False)
appName.background = 240,240,240
instructions = JTextArea(' Ever agonized over whether or not your emails' +
' are polite enough? \n Never fear! With our politeness gauge' +
' we can provide suggestions on improving your emails' +
' with just the click of a button. \n Just type your email ' +
'into the text box below and hit Score!')
instructions.setLineWrap(True)
instructions.setWrapStyleWord(True)
instructions.background = 240,240,240
northPanel = JPanel(GridLayout(2,1))
northPanel.add(appName)
northPanel.add(instructions)
self.subPanel1.add(northPanel, BorderLayout.NORTH)
self.userText.setEditable(True)
self.userText.setLineWrap(True)
self.userText.setWrapStyleWord(True)
self.userText.setRows(100)
#self.userText.wordWrap = True
self.subPanel1.add(self.userText, BorderLayout.CENTER)
self.subPanel1.add(self.button, BorderLayout.SOUTH)
label = JLabel("Politeness Evaluation")
self.subPanel2.add(label)
self.subPanel2.add(self.emoticonFeedback)
self.subPanel2.add(self.curseFeedback)
self.subPanel2.add(self.styleFeedback)
self.subPanel2.add(self.overallFeedback)
self.mainPanel.add(self.subPanel1)
self.mainPanel.add(self.subPanel2)
示例2: main
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [as 别名]
def main():
binNaviProxy = StandAlone.getPluginInterface()
binNaviProxy.databaseManager.addDatabase("","com.mysql.jdbc.Driver","localhost","BINNAVI1","binnavi","binnavi",False,False)
db=binNaviProxy.databaseManager.databases[0]
db.connect()
db.load()
mods=db.getModules()
### initiate dialogBox to setect the module that should be used.
######################################################
frame = JFrame('BinNavi Module Selector',layout=BorderLayout(),
defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
size = (1500, 800)
)
frame2 = JFrame('Function Selector',layout=BorderLayout(),
defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
size = (30, 30)
)
frame2.setFocusableWindowState(False)
frame2.setFocusable(False)
frame2.setAlwaysOnTop(False)
#convert the module list into the string to be used in the TextBox.
textTemp = map((lambda x,y:"[%d]%s"%(x,y)),range(len(mods)),mods)
textStr=''.join(textTemp)
tx=JTextArea(textStr)
tx.setLineWrap(True);
tx.setWrapStyleWord(True);
frame.add(tx,BorderLayout.PAGE_START)
frame.visible = True
modInd = JOptionPane.showInputDialog(frame2, "Enter the index of the chosen module",
"Module selector");
#Open the module returned by the index
bfname=mods[int(modInd)] # this modules correxponds to the chosen module
bfname.load()
funcViews=bfname.views
#textTemp2 = ["[%d]%s"%(i,j) for i in range(len(funcViews)) for j in funcViews]
textTemp2=map((lambda x,y:"[%d]%s"%(x,y.toString()[5:18])),range(len(funcViews)),funcViews)
textStr1=''.join(textTemp2)
## remove the older text from the frame view
frame.remove(tx)
frame.update(frame.getGraphics())
frame.visible = False
## create a new textArea with the string made from all the functions' name
txStr=JTextArea(textStr1)
#tx.setsrcollOffset(20)
txStr.setLineWrap(True);
txStr.setWrapStyleWord(True);
frame.add(txStr,BorderLayout.PAGE_START)
frame.update(frame.getGraphics())
frame.visible = True
funcInd = JOptionPane.showInputDialog(frame2, "Enter the index of the function",
"Function selector");
######################################################
bffunc=bfname.views[int(funcInd)] #this is the view of the buildfname function
bffunc.load()
frame2.setVisible(False)
dispose(frame2)
bfReil=bffunc.getReilCode() # this is the REIL code of the function
bfReilGraph=bfReil.getGraph()
instGraph = InstructionGraph.create(bfReilGraph)
time.clock()
results=doAnalysis(instGraph)
totalTime=time.clock()
#print "resultsLen", len([r for r in results])
print "**** printing results *******\n"
print "Total time:", totalTime, '\n'
numNode=0
for n in instGraph:
numNode+=numNode
nIn=list(results.getState(n).inVal)
nIn.sort(key=itemgetter(0))
nOut=list(results.getState(n).out)
nOut.sort(key=itemgetter(0))
print '@@ ',n.getInstruction(),'\n'
print '\t In', nIn, '\n'
print '\t OUT', nOut, '\n'
print '\t memory: ',results.getState(n).memoryWritten, '\n'
print "++++ Total instructions: %d +++++\n"%numNode
#finally close the view of the function
bffunc.close()
#print bffunc.isLoaded()
#junky=raw_input("function closed. enter any charater")
#.........这里部分代码省略.........
示例3: BurpExtender
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [as 别名]
#.........这里部分代码省略.........
self.filtersPnl.add(IFLabelList)
self.filtersPnl.add(self.IFList)
def initConfigurationTab(self):
#
## init configuration tab
#
self.prevent304 = JCheckBox("Prevent 304 Not Modified status code")
self.prevent304.setBounds(290, 25, 300, 30)
self.ignore304 = JCheckBox("Ignore 304/204 status code responses")
self.ignore304.setBounds(290, 5, 300, 30)
self.ignore304.setSelected(True)
self.autoScroll = JCheckBox("Auto Scroll")
#self.autoScroll.setBounds(290, 45, 140, 30)
self.autoScroll.setBounds(160, 40, 140, 30)
self.doUnauthorizedRequest = JCheckBox("Check unauthenticated")
self.doUnauthorizedRequest.setBounds(290, 45, 300, 30)
self.doUnauthorizedRequest.setSelected(True)
startLabel = JLabel("Authorization checks:")
startLabel.setBounds(10, 10, 140, 30)
self.startButton = JButton("Autorize is off",actionPerformed=self.startOrStop)
self.startButton.setBounds(160, 10, 120, 30)
self.startButton.setBackground(Color(255, 100, 91, 255))
self.clearButton = JButton("Clear List",actionPerformed=self.clearList)
self.clearButton.setBounds(10, 40, 100, 30)
self.replaceString = JTextArea("Cookie: Insert=injected; header=here;", 5, 30)
self.replaceString.setWrapStyleWord(True);
self.replaceString.setLineWrap(True)
self.replaceString.setBounds(10, 80, 470, 180)
self.filtersTabs = JTabbedPane()
self.filtersTabs.addTab("Enforcement Detector", self.EDPnl)
self.filtersTabs.addTab("Detector Unauthenticated", self.EDPnlUnauth)
self.filtersTabs.addTab("Interception Filters", self.filtersPnl)
self.filtersTabs.addTab("Export", self.exportPnl)
self.filtersTabs.setBounds(0, 280, 2000, 700)
self.pnl = JPanel()
self.pnl.setBounds(0, 0, 1000, 1000);
self.pnl.setLayout(None);
self.pnl.add(self.startButton)
self.pnl.add(self.clearButton)
self.pnl.add(self.replaceString)
self.pnl.add(startLabel)
self.pnl.add(self.autoScroll)
self.pnl.add(self.ignore304)
self.pnl.add(self.prevent304)
self.pnl.add(self.doUnauthorizedRequest)
self.pnl.add(self.filtersTabs)
def initTabs(self):
#
## init autorize tabs
#
self.logTable = Table(self)
self.logTable.setAutoCreateRowSorter(True)
示例4: main
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [as 别名]
def main():
'''
Main function that implements main algorithm
'''
# a file where some log will be created which says how many functions are discovered etc.
logFile=raw_input("Enter the name of log file")
# this is provided as an extra file which is a pickled file comtains a list of functions
# that are found to be BOP. Its main purpose is: if you want to use these functions for some
# other analysis, just load this file and viola!!!
fileBOP=raw_input("Enter the file name (full path) to store (Pickled) BOP function's name: ")
interestingFuncs={} # dictionary of interesting functions
interestingFuncsLOC={} # dictionary of LOC in interesting functions
binNaviProxy = StandAlone.getPluginInterface()
################## place to set database connectivity parameter #########
binNaviProxy.databaseManager.addDatabase("","org.postgresql.Driver","localhost","DataBase_name","user","password",False,False)
########################################################################
db=binNaviProxy.databaseManager.databases[0]
db.connect()
db.load()
mods=db.getModules()
### initiate dialogBox to setect the module that should be used.
######################################################
frame = JFrame('BinNavi Module Selector',layout=BorderLayout(),
defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
size = (500, 500)
)
frame2 = JFrame('Function Selector',layout=BorderLayout(),
defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
size = (30, 30)
)
#convert the module list into the string to be used in the TextBox.
## This gives a very ugly box to select the required function (yes, I am bit lazy to learn Java Swing!!).
textTemp = map((lambda x,y:"[%d]%s"%(x,y)),range(len(mods)),mods)
textStr=''.join(textTemp)
tx=JTextArea(textStr)
tx.setLineWrap(True);
tx.setWrapStyleWord(True);
frame.add(tx,BorderLayout.PAGE_START)
frame.visible = True
modInd = JOptionPane.showInputDialog(frame2, "Enter the index of the chosen module",
"Module selector");
#Open the module returned by the index
bfname=mods[int(modInd)] # this modules correxponds to the chosen module
bfname.load()
funcViews=bfname.views
frame2.setVisible(False)
dispose(frame2)
######################################################
analyzedFunctions = 0
totalDiscoveredLoops=0
totalInterestingLoops=0
time.clock()
for funcInd in range(1,len(funcViews)):
BBnum=funcViews[funcInd].getNodeCount()
if BBnum <4:
print "skipped"
continue #do not analyse function if num of BB less than 4
print 'analyzing %s'%funcViews[funcInd].getName()
dominatingSets={}#dictionary to keep dominating nodes of a node
bffunc=bfname.views[int(funcInd)] #this is the view of the buildfname function
bffunc.load()
try:
bfReil=bffunc.getReilCode() # this is the REIL code of the function
except:
print "error in getReilCode()"
bffunc.close()
gc.collect()
continue
bfReilGraph=bfReil.getGraph()
try:
#dominatorTree = GraphAlgorithms.getDominatorTree(bfReilGraph, findRoot(bfReilGraph.getNodes())) #only for BinNavi v 3.0
dominatorTree = GraphAlgorithms.getDominatorTree(bfReilGraph, findRoot(bfReilGraph.getNodes()),None)
except:
print "dominator tree problem.. continue with the next function"
bffunc.close()
gc.collect()
continue
fillDominatingSets(dominatorTree.getRootNode(), dominatingSets, None)
#.........这里部分代码省略.........
示例5: ChannelPanel
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [as 别名]
class ChannelPanel(JPanel):
gbc = GridBagConstraints()
def __init__(self):
JPanel.__init__(self)
self.setLayout(GridBagLayout())
self.setBorder(TitledBorder("Channel"))
# some helper constants
REL = GridBagConstraints.RELATIVE
REM = GridBagConstraints.REMAINDER
HORIZ = GridBagConstraints.HORIZONTAL
NW = GridBagConstraints.NORTHWEST
CENTER = GridBagConstraints.CENTER
# --- title
label = JLabel("Title:")
self.constrain(label, REL, REL, REL, 1,
HORIZ, CENTER, 1.0, 1.0,
2, 2, 2, 2)
self.field_title = JTextField()
self.field_title.setEditable(0)
self.constrain(self.field_title, REL, REL, REM, 1,
HORIZ, CENTER, 1.0, 1.0,
2, 2, 2, 2)
# --- description
label = JLabel("Description:")
self.constrain(label, REL, REL, REL, 1,
HORIZ, NW, 1.0, 1.0,
2, 2, 2, 2)
self.field_descr = JTextArea(3, 40)
self.field_descr.setEditable(0)
# wrap long lines
self.field_descr.setLineWrap(1)
# allow only full words to be wrapped
self.field_descr.setWrapStyleWord(1)
# ensure that the border look is the same
self.field_descr.setBorder(self.field_title.getBorder())
self.constrain(self.field_descr, REL, REL, REM, 1,
HORIZ, NW, 1.0, 1.0,
2, 2, 2, 2)
# --- location
label = JLabel("Location:")
self.constrain(label, REL, REL, REL, 1,
HORIZ, NW, 1.0, 1.0,
2, 2, 2, 2)
self.field_location = JTextField()
self.constrain(self.field_location, REL, REL, REM, REL,
HORIZ, NW, 1.0, 1.0,
2, 2, 2, 2)
# --- last update
label = JLabel("Last Update:")
self.constrain(label, REL, REL, REL, REM,
HORIZ, NW, 1.0, 1.0,
2, 2, 2, 2)
self.field_lastupdate = JTextField()
self.field_lastupdate.setEditable(0)
self.constrain(self.field_lastupdate, REL, REL, REM, REM,
HORIZ, NW, 1.0, 1.0,
2, 2, 2, 2)
def setChannel(self, channel):
self.channel = channel
self.field_title.setText(channel.getTitle())
self.field_descr.setText(channel.getDescription())
self.field_location.setText(channel.getLocation().toString())
self.field_lastupdate.setText(channel.getSubscription().getLastUpdated().toString())
def refresh(self):
self.setChannel(self.channel)
def constrain(self, component,
grid_x, grid_y, grid_width, grid_height,
fill, anchor, weight_x, weight_y,
top, left, bottom, right):
container = self
c = self.gbc
c.gridx = grid_x
c.gridy = grid_y
c.gridwidth = grid_width
c.gridheight = grid_height
c.fill = fill
c.anchor = anchor
c.weightx = weight_x
c.weighty = weight_y
if (top + bottom + left + right > 0):
c.insets = Insets(top, left, bottom, right)
container.getLayout().setConstraints(component, c)
container.add(component)
示例6: BurpExtender
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [as 别名]
class BurpExtender(IBurpExtender, ITab, IHttpListener, IMessageEditorController, AbstractTableModel):
#
# implement IBurpExtender
#
def registerExtenderCallbacks(self, callbacks):
# 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("Otter")
# create the log and a lock on which to synchronize when adding log entries
self._log = ArrayList()
self._lock = Lock()
# main split pane for log entries and request/response viewing
self._settingPanel = JPanel()
self._logPane = JSplitPane(JSplitPane.VERTICAL_SPLIT)
# setup settings pane ui
self._settingPanel.setBounds(0,0,1000,1000)
self._settingPanel.setLayout(None)
self._isRegexp = JCheckBox("Use regexp for matching.")
self._isRegexp.setBounds(10, 10, 220, 20)
matchLabel = JLabel("String to Match:")
matchLabel.setBounds(10, 40, 200, 20)
self._matchString = JTextArea("User 1 Session Information")
self._matchString.setWrapStyleWord(True)
self._matchString.setLineWrap(True)
matchString = JScrollPane(self._matchString)
matchString.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED)
matchString.setBounds(10, 60, 400, 200)
replaceLabel = JLabel("String to Replace:")
replaceLabel.setBounds(10, 270, 200, 20)
self._replaceString = JTextArea("User 2 Session Information")
self._replaceString.setWrapStyleWord(True)
self._replaceString.setLineWrap(True)
replaceString = JScrollPane(self._replaceString)
replaceString.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED)
replaceString.setBounds(10, 290, 400, 200)
self._settingPanel.add(self._isRegexp)
self._settingPanel.add(matchLabel)
self._settingPanel.add(matchString)
self._settingPanel.add(replaceLabel)
self._settingPanel.add(replaceString)
# table of log entries
logTable = Table(self)
logTable.getColumnModel().getColumn(0).setPreferredWidth(700)
logTable.getColumnModel().getColumn(1).setPreferredWidth(150)
logTable.getColumnModel().getColumn(2).setPreferredWidth(100)
logTable.getColumnModel().getColumn(3).setPreferredWidth(130)
logTable.getColumnModel().getColumn(4).setPreferredWidth(100)
logTable.getColumnModel().getColumn(5).setPreferredWidth(130)
scrollPane = JScrollPane(logTable)
self._logPane.setLeftComponent(scrollPane)
# tabs with request/response viewers
logTabs = JTabbedPane()
self._origRequestViewer = callbacks.createMessageEditor(self, False)
self._origResponseViewer = callbacks.createMessageEditor(self, False)
self._modRequestViewer = callbacks.createMessageEditor(self, False)
self._modResponseViewer = callbacks.createMessageEditor(self, False)
logTabs.addTab("Original Request", self._origRequestViewer.getComponent())
logTabs.addTab("Original Response", self._origResponseViewer.getComponent())
logTabs.addTab("Modified Request", self._modRequestViewer.getComponent())
logTabs.addTab("Modified Response", self._modResponseViewer.getComponent())
self._logPane.setRightComponent(logTabs)
# top most tab interface that seperates log entries from settings
maintabs = JTabbedPane()
maintabs.addTab("Log Entries", self._logPane)
maintabs.addTab("Settings", self._settingPanel)
self._maintabs = maintabs
# customize the UI components
callbacks.customizeUiComponent(maintabs)
# add the custom tab to Burp's UI
callbacks.addSuiteTab(self)
# register ourselves as an HTTP listener
callbacks.registerHttpListener(self)
return
#
# implement ITab
#
#.........这里部分代码省略.........
示例7: gui
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [as 别名]
class gui(JFrame):
def __init__(self):
#Class variable declarations
self.mainPanel = JPanel(GridLayout(1,2))
self.subPanel1 = JPanel(BorderLayout())
self.subPanel2 = JPanel(GridLayout(5,1))
self.userText = JTextArea(' ')
self.emoticonFeedback = JTextArea('This will consider your emoticon usage.')
self.curseFeedback = JTextArea('This will consider your use of profanity.')
self.styleFeedback = JTextArea('This will consider your general tone.')
self.overallFeedback = JTextArea('This will be your overall score.')
self.button = JButton("Score my email!",
actionPerformed=self.updateScores)
self.initGUI()
self.add(self.mainPanel)
self.setSize(800, 500)
self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
self.setVisible(True)
def initGUI(self):
#Set up subpanel1
appName = JTextArea('Politeness Gauge\n'+'\nSarah Robinson \nAnna Clegg')
appName.setLineWrap(True)
appName.setWrapStyleWord(True)
appName.setEditable(False)
appName.background = 240,240,240
instructions = JTextArea(' Ever agonized over whether or not your emails' +
' are polite enough? \n Never fear! With our politeness gauge' +
' we can provide suggestions on improving your emails' +
' with just the click of a button. \n Just type your email ' +
'into the text box below and hit Score!')
instructions.setLineWrap(True)
instructions.setWrapStyleWord(True)
instructions.background = 240,240,240
northPanel = JPanel(GridLayout(2,1))
northPanel.add(appName)
northPanel.add(instructions)
self.subPanel1.add(northPanel, BorderLayout.NORTH)
self.userText.setEditable(True)
self.userText.setLineWrap(True)
self.userText.setWrapStyleWord(True)
self.userText.setRows(100)
#self.userText.wordWrap = True
self.subPanel1.add(self.userText, BorderLayout.CENTER)
self.subPanel1.add(self.button, BorderLayout.SOUTH)
label = JLabel("Politeness Evaluation")
self.subPanel2.add(label)
self.subPanel2.add(self.emoticonFeedback)
self.subPanel2.add(self.curseFeedback)
self.subPanel2.add(self.styleFeedback)
self.subPanel2.add(self.overallFeedback)
self.mainPanel.add(self.subPanel1)
self.mainPanel.add(self.subPanel2)
def updateScores(self, event):
input = self.userText.getText()
scores = mes.get_scores(input)
overall = mes.get_overall_score()
self.styleFeedback.setText("\n Your politeness score is "+str(scores['politeness'])
+".\n Higher is better. This is relative to the\n length of your email,"
+" so the more sentences you have,\n the higher this score should be.")
self.curseFeedback.setText(" You have about " +str(scores['curses'])+" curses in you email."
+"\n Please try to have 0 curses.")
self.emoticonFeedback.setText(" You have about "+str(scores['emoticons'])+" emoticons in your email."
+"\n Fewer emoticons is considered more professional.")
self.overallFeedback.setText(" Your overall professionality score is "+str(overall)+"."
+"\n The baseline is around 50 for neutral emails."
+"\n Please remember that this is approximate.")
示例8: getIp
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [as 别名]
class JTabbedPaneClass:
#判断域名返回IP地址
def getIp(self, domain):
domain = domain.split(":")[0]
ipExpression = re.compile('^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$')
domainExpression = re.compile("^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$")
if ipExpression.match(domain):
return domain
elif domainExpression.match(domain):
myAddr = socket.getaddrinfo(domain,'http')[0][4][0]
return myAddr
else:
return "domain error"
#提取域名或IP信息
def getDomain1(self, theDomain):
domain1 = theDomain.split(":")[0]
return domain1
def __init__(self):
frame = JFrame("S1riu5 Spy")
frame.setSize(700, 690)
frame.setLocationRelativeTo(None);
frame.setLayout(BorderLayout())
tabPane = JTabbedPane(JTabbedPane.TOP)
#第一个Tab用来做C段查询
eachIp = self.getIp(HOSTDOMAIN)
iList = eachIp.split(".")
theIP = iList[0] + "." + iList[1] + "." + iList[2] + ".1/24"
panel1 = JPanel()
label = JLabel("IP CIDR:")
self.textfield1 = JTextField(theIP, 15)
button = JButton("SCAN", actionPerformed = self.cNmapScan)
self.textArea = JTextArea(40, 65)
self.textArea.append("IP: " + eachIp)
self.textArea.setLineWrap(True) #激活自动换行功能
self.textArea.setWrapStyleWord(True); # 激活断行不断字功能
panel1.add(label)
panel1.add(self.textfield1)
panel1.add(button)
panel1.add(JScrollPane(self.textArea)) #设置自动滚动条
tabPane.addTab("C segment query ", panel1)
#第二个Tab用来做子域名查询
theName = self.getDomain1(HOSTDOMAIN)
self.textArea2 = JTextArea(40, 65)
#self.textArea.append("IP: " + eachIp)
self.textArea2.setLineWrap(True) #激活自动换行功能
self.textArea2.setWrapStyleWord(True) # 激活断行不断字功能
label2 = JLabel("Domain: ")
self.textfield2 = JTextField(theName, 15)
button2 = JButton("SCAN", actionPerformed = self.subDomain)
self.panel2 = JPanel()
self.panel2.add(label2)
self.panel2.add(self.textfield2)
self.panel2.add(button2)
#self.panel2.add(scrollPane)
self.panel2.add(JScrollPane(self.textArea2))
tabPane.addTab("subDomains", self.panel2)
#第三个Tab用来做敏感文件扫描
self.tableData0 = [["1", "2"]]
colNames2 = ('url','http code')
dataModel3 = DefaultTableModel(self.tableData0, colNames2)
self.table3 = JTable(dataModel3)
##
label3 = JLabel("URL: ")
self.textfield3 = JTextField(HOSTDOMAIN, 15)
self.textArea3 = JTextArea(40, 65)
#self.textArea.append("IP: " + eachIp)
self.textArea3.setLineWrap(True) #激活自动换行功能
#.........这里部分代码省略.........
示例9: appendText
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [as 别名]
def appendText(self, message, user=None):
'''This function takes care of appending any new messages to the content area
'''
message_label=JTextArea(message,2,3, font=self.label_2_font)
# If this is a message from the grab text function, create a new label, assign it's colours
if user!=None:
message_label.setBackground(Color(240,240,240))
message_label.setForeground(Color(129,129,129))
# Otherwise set the format for receive function (no user passed in)
else:
message_label.setBackground(Color(215,215,215))
message_label.setForeground(Color(40,153,153))
# Format and style options for the new message labels
message_label.setEditable(False)
message_label.setLineWrap(True)
message_label.setWrapStyleWord(True)
message_label.setBorder(BorderFactory.createLineBorder( Color(247,246,242),4))
# Sets the positioning of messages
self.main_content.setCaretPosition(self.main_content.getDocument().getLength())
doc = self.main_content.getStyledDocument()
attr=SimpleAttributeSet()
self.main_content.insertComponent(message_label)
# Essential for jtextarea to be able to stack message
doc.insertString( self.main_content.getDocument().getLength(),'\n ', attr)
# Not sure if needed
self.main_content.repaint()
### This is a late edit so it isn't included in the documentation. Basically trying to dynamically update the number
### of users label at runtime. Works for incrementing the value but not decrementing it.
print(message)
# Only split the message if there are enough values to split (greeting messages differ in format to chat messages)
try:
user, text=message.split(' : ')
except:
return
#print('Split values are %s %s'%(user, text))
user=str(user.strip())
#print(self.no_users)
#print(user+' : '+text)
# If the user already in the list, pass
if user in self.no_users:
if text == ('User %s amach sa teach !'%user):
self.no_users.remove(user)
print('User % removed'%user)
else:
#print('User %s not in list'%user)
if str(user) == 'You':
#print('User is equal to "You"')
return
self.no_users.append(user)
print('User appended')
self.number_users=len(self.no_users)
#print('Length of user list is '+str(self.number_users))
self.user_label2=JLabel(" Users online : %s "%str(len(self.no_users)),JLabel.RIGHT, font=self.label_2_font)
#print('Label created')
#print('Attempt to replace label')
self.client_layout.replace(self.user_label, self.user_label2)
self.user_label = self.user_label2
self.user_label.repaint()
self.user_label.revalidate()
print('Label updated')
示例10: ChatClient
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [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))
#.........这里部分代码省略.........
示例11: BurpExtender
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [as 别名]
#.........这里部分代码省略.........
copyImgMenu = JMenuItem("Copy")
copyImgMenu.addActionListener(copyImg(self))
self.imgMenu = JPopupMenu("Popup")
self.imgMenu.add(copyImgMenu)
self.firstPic = JLabel()
self.firstPic.setBorder(BorderFactory.createLineBorder(Color.GRAY))
self.firstPic.setBounds(580, 320, 550, 400)
self.firstPic.addMouseListener(imageClicked(self))
self.vulnName = JTextField("")
self.vulnName.getDocument().addDocumentListener(vulnTextChanged(self))
self.vulnName.setBounds(140, 10, 422, 30)
sevirities = ["Unclassified", "Critical","High","Medium","Low"]
self.threatLevel = JComboBox(sevirities);
self.threatLevel.setBounds(140, 45, 140, 30)
colors = ["Color:", "Green", "Red"]
self.colorCombo = JComboBox(colors);
self.colorCombo.setBounds(465, 45, 100, 30)
self.colorCombo
severityLabel = JLabel("Threat Level:")
severityLabel.setBounds(10, 45, 100, 30)
descriptionLabel = JLabel("Description:")
descriptionLabel.setBounds(10, 80, 100, 30)
self.descriptionString = JTextArea("", 5, 30)
self.descriptionString.setWrapStyleWord(True);
self.descriptionString.setLineWrap(True)
self.descriptionString.setBounds(10, 110, 555, 175)
descriptionStringScroll = JScrollPane(self.descriptionString)
descriptionStringScroll.setBounds(10, 110, 555, 175)
descriptionStringScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED)
self.mitigationStr = JTextArea("", 5, 30)
self.mitigationStr.setWrapStyleWord(True);
self.mitigationStr.setLineWrap(True)
self.mitigationStr.setBounds(10, 320, 555, 175)
mitigationStrScroll = JScrollPane(self.mitigationStr)
mitigationStrScroll.setBounds(10, 320, 555, 175)
mitigationStrScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED)
self.pnl = JPanel()
self.pnl.setBounds(0, 0, 1000, 1000);
self.pnl.setLayout(None);
self.pnl.add(addSSBtn)
self.pnl.add(piclistLabel)
self.pnl.add(nameLabel)
self.pnl.add(deleteSSBtn)
self.pnl.add(rmVulnButton)
self.pnl.add(severityLabel)
self.pnl.add(mitigationLabel)
self.pnl.add(descriptionLabel)
self.pnl.add(previewPicLabel)
self.pnl.add(mitigationStrScroll)
self.pnl.add(descriptionStringScroll)
self.pnl.add(self.ssList)
self.pnl.add(self.firstPic)
示例12: ConsolePanel
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [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
#.........这里部分代码省略.........
示例13: JButton
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setWrapStyleWord [as 别名]
frame.dispose()
jB2 = JButton("Exit", actionPerformed=exitme)
lowerPanel.add(jB2);
topPanel.setLayout(BorderLayout());
# comments
jScrollPane1 = JScrollPane();
jScrollPane1.getViewport().add( jDescription );
topPanel.add(jScrollPane1,BorderLayout.CENTER);
jDescription.setLineWrap(1);
jDescription.setWrapStyleWord(1);
jDescription.setCaretColor(Color.red);
frame.add( topPanel, BorderLayout.CENTER );
frame.add( lowerPanel, BorderLayout.SOUTH );
bounds = view.getBounds()
ww = bounds.width
hh= bounds.height
xx = bounds.x
yy = bounds.y
frame.setLocation(xx+(int)(0.4*ww), yy+(int)(0.1*hh))
frame.pack()
frame.setSize( (int)(0.5*ww),(int)(0.8*hh) );
frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)