本文整理汇总了Python中javax.swing.JTextField.setEditable方法的典型用法代码示例。如果您正苦于以下问题:Python JTextField.setEditable方法的具体用法?Python JTextField.setEditable怎么用?Python JTextField.setEditable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextField
的用法示例。
在下文中一共展示了JTextField.setEditable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HumanDetailPanel
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import setEditable [as 别名]
class HumanDetailPanel(DetailPanel):
""" generated source for class HumanDetailPanel """
moveTable = JZebraTable()
moveTextField = JTextField()
selectButton = JButton()
selection = Move()
timerBar = JTimerBar()
def __init__(self):
""" generated source for method __init__ """
super(HumanDetailPanel, self).__init__(GridBagLayout())
model = DefaultTableModel()
model.addColumn("Legal Moves")
self.moveTable = JZebraTable(model)
self.selectButton = JButton(selectButtonMethod())
self.moveTextField = JTextField()
self.timerBar = JTimerBar()
self.selection = None
self.moveTable.setShowHorizontalLines(True)
self.moveTable.setShowVerticalLines(True)
self.moveTextField.setEditable(False)
self.add(JScrollPane(self.moveTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, Insets(5, 5, 5, 5), 5, 5))
self.add(self.selectButton, GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, Insets(5, 5, 5, 5), 0, 0))
self.add(self.moveTextField, GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, Insets(5, 5, 5, 5), 5, 5))
self.add(self.timerBar, GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, Insets(5, 5, 5, 5), 5, 5))
@overloaded
def observe(self, event):
""" generated source for method observe """
if isinstance(event, (HumanNewMovesEvent, )):
self.observe(event)
elif isinstance(event, (HumanTimeoutEvent, )):
self.observe(event)
elif isinstance(event, (PlayerTimeEvent, )):
self.observe(event)
@observe.register(object, HumanNewMovesEvent)
def observe_0(self, event):
""" generated source for method observe_0 """
model = self.moveTable.getModel()
model.setRowCount(0)
for move in event.getMoves():
model.addRow([None]*)
self.selection = event.getSelection()
self.moveTextField.setText(self.selection.__str__())
@observe.register(object, HumanTimeoutEvent)
def observe_1(self, event):
""" generated source for method observe_1 """
event.getHumanPlayer().setMove(self.selection)
@observe.register(object, PlayerTimeEvent)
def observe_2(self, event):
""" generated source for method observe_2 """
self.timerBar.time(event.getTime(), 500)
def selectButtonMethod(self):
""" generated source for method selectButtonMethod """
return AbstractAction("Select")
示例2: ChannelPanel
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import setEditable [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)
示例3: EditSettingsView
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import setEditable [as 别名]
class EditSettingsView(JDialog):
def __init__(self, controller, working_dir, servers, console_style,
edit_area_style, keystrokes, languages, projects):
self.logger = logging.getLogger("NammuController")
self.setAlwaysOnTop(True)
self.controller = controller
self.working_dir = working_dir
self.servers = servers
self.keystrokes = keystrokes
self.languages = languages
self.projects = projects
self.console_fontsize = console_style['fontsize']['user']
self.console_font_color = console_style['font_color']['user']
self.console_bg_color = console_style['background_color']['user']
self.edit_area_fontsize = edit_area_style['fontsize']['user']
self.pane = self.getContentPane()
# Grab the console color options from the console view
self.consoleView = self.controller.controller.consoleController.view
self.color_options = self.consoleView.colors.keys()
def build(self):
'''
Create all tab panels and put together to form the settings window.
'''
self.setLayout(BorderLayout())
self.add(self.build_tabbed_panel(), BorderLayout.CENTER)
self.add(self.build_buttons_panel(), BorderLayout.SOUTH)
def build_tabbed_panel(self):
'''
Build panel with tabs for each of the settings editable sections.
'''
tabbed_pane = JTabbedPane()
tab_titles = ["General", "Appearance", "Keystrokes", "Languages",
"Projects"]
for title in tab_titles:
panel = self.build_settings_panel(title.lower())
tabbed_pane.addTab(title, panel)
return tabbed_pane
def build_settings_panel(self, text):
'''
Call correspondent method to create panel for given tab text.
'''
panel = getattr(self, "build_{}_panel".format(text))()
return panel
def build_general_panel(self):
'''
Create the panel that'll go in the General tab. This should contain
options for choosing which server to use for validation as well as
default working dir.
'''
panel = JPanel(GridBagLayout())
constraints = self.add_constraints(GridBagConstraints(),
insets=Insets(10, 10, 10, 10))
self.build_working_dir_panel(constraints, panel)
self.build_servers_panel(constraints, panel)
return panel
def add_constraints(self, constraints, weightx=None, gridx=None,
gridy=None, fill=None, insets=None, gridwidth=None,
anchor=None):
'''
Wrapper around the various constraints we need to set.
'''
# Cant use pythonic truth value test as we need 0 to evaluate as true
if weightx is not None:
constraints.weightx = weightx
if gridx is not None:
constraints.gridx = gridx
if gridy is not None:
constraints.gridy = gridy
if fill is not None:
constraints.fill = fill
if insets is not None:
constraints.insets = insets
if gridwidth is not None:
constraints.gridwidth = gridwidth
if anchor is not None:
constraints.anchor = anchor
return constraints
def build_working_dir_panel(self, constraints, panel):
'''
Working directory row: label + field + button
This is for users to browse for their preferred default directory
when opening/creating a new file.
'''
working_dir_label = JLabel("Working directory:")
constraints = self.add_constraints(constraints, weightx=0.30,
gridx=0, gridy=0,
anchor=GridBagConstraints.EAST)
panel.add(working_dir_label, constraints)
self.wd_field = JTextField()
self.wd_field.setEditable(False)
#.........这里部分代码省略.........
示例4: ChatApp
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import setEditable [as 别名]
class ChatApp(JFrame):
## Constructor function, initiate the base classes and call the GUI
def __init__(self):
'''Calls the base class and main UI
'''
# Call to the super class, initiates associated base classes
super(ChatApp, self).__init__()
# Call the Initial UI
self.initUI()
## Build the GUI for login, uses GroupLayout Manager for component positioning
def initUI(self):
'''Initial UI and Widget creation takes place here!
'''
self.setContentPane = JPanel()
#self.setDefaultLookAndFeelDecorated(True)
# Borders
foreground_colour = Color(30,57,68)
background_colour = Color(247,246,242)
window_background = Color(145,190,210)
self.border = BorderFactory.createLoweredBevelBorder()
self.border2 = BorderFactory.createLineBorder(foreground_colour, 1, True)
# Fonts
self.entry_font= Font("Ubuntu Light", Font.BOLD, 20)
self.label_font= Font("Ubuntu Light", Font.BOLD, 17)
self.btn_font=Font("Ubuntu Light", Font.BOLD, 15)
# Layout start
layout=GroupLayout(self.getContentPane())
self.getContentPane().setLayout(layout)
layout.setAutoCreateGaps(True)
layout.setAutoCreateContainerGaps(True)
self.setPreferredSize(Dimension(300, 150))
# Create the labels
user_label= JLabel(" Username : ",JLabel.LEFT, font=self.label_font)
server_label=JLabel(" Server : ", JLabel.LEFT, font=self.label_font)
# Colours
user_label.setForeground(foreground_colour)
server_label.setForeground(foreground_colour)
# Create the text entries
self.username=JTextField(actionPerformed=self.continueEvent, border=self.border2, font = self.entry_font)
self.server=JTextField(actionPerformed=self.continueEvent, border=self.border2, font = self.entry_font)
# Colours
self.username.setBackground(background_colour)
self.server.setBackground(background_colour)
self.username.setForeground(foreground_colour)
self.server.setForeground(foreground_colour)
# Allow editable
self.username.setEditable(True)
self.server.setEditable(True)
# Create the buttons
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
#.........这里部分代码省略.........
示例5: ConsolePanel
# 需要导入模块: from javax.swing import JTextField [as 别名]
# 或者: from javax.swing.JTextField import setEditable [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
#.........这里部分代码省略.........