本文整理汇总了Java中javax.swing.JTextField.selectAll方法的典型用法代码示例。如果您正苦于以下问题:Java JTextField.selectAll方法的具体用法?Java JTextField.selectAll怎么用?Java JTextField.selectAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextField
的用法示例。
在下文中一共展示了JTextField.selectAll方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFind
import javax.swing.JTextField; //导入方法依赖的package包/类
/** This method performs Edit->Find. */
private Runner doFind() {
if (wrap)
return wrapMe();
JTextField x = OurUtil.textfield(lastFind, 30);
x.selectAll();
JCheckBox c = new JCheckBox("Case Sensitive?", lastFindCaseSensitive);
c.setMnemonic('c');
JCheckBox b = new JCheckBox("Search Backward?", !lastFindForward);
b.setMnemonic('b');
if (!OurDialog.getInput("Find", "Text:", x, " ", c, b))
return null;
if (x.getText().length() == 0)
return null;
lastFind = x.getText();
lastFindCaseSensitive = c.getModel().isSelected();
lastFindForward = !b.getModel().isSelected();
doFindNext();
return null;
}
示例2: setValueFromGUI
import javax.swing.JTextField; //导入方法依赖的package包/类
private void setValueFromGUI(final JTextField tf) {
final AbstractMultiBitRegisterCP embeddingCP = (AbstractMultiBitRegisterCP) tf.getParent();
embeddingCP.startEdit();
try {
embeddingCP.reg.setPartialValue(componentID, Integer.parseInt(tf.getText()));
embeddingCP.reg.setFileModified();
tf.setBackground(Color.white);
}
catch (final Exception ex) {
tf.selectAll();
tf.setBackground(Color.red);
log.warning(ex.toString());
}
finally {
embeddingCP.endEdit();
}
}
示例3: incValueAndUpdateGUI
import javax.swing.JTextField; //导入方法依赖的package包/类
private void incValueAndUpdateGUI(int inc, final JTextField tf) {
final AbstractMultiBitRegisterCP embeddingCP = (AbstractMultiBitRegisterCP) tf.getParent();
embeddingCP.startEdit();
try {
embeddingCP.reg.setPartialValue(componentID, embeddingCP.reg.getPartialValue(componentID) + inc);
embeddingCP.reg.setFileModified();
tf.setBackground(Color.white);
}
catch (final Exception ex) {
tf.selectAll();
tf.setBackground(Color.red);
log.warning(ex.toString());
}
finally {
embeddingCP.endEdit();
}
}
示例4: startRename
import javax.swing.JTextField; //导入方法依赖的package包/类
private void startRename() {
// init the text box
final JTextField text = new JTextField();
text.setText(m_reference.getNamableName());
text.setPreferredSize(new Dimension(360, text.getPreferredSize().height));
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
switch (event.getKeyCode()) {
case KeyEvent.VK_ENTER:
finishRename(text, true);
break;
case KeyEvent.VK_ESCAPE:
finishRename(text, false);
break;
}
}
});
// find the label with the name and replace it with the text box
JPanel panel = (JPanel)m_infoPanel.getComponent(0);
panel.remove(panel.getComponentCount() - 1);
panel.add(text);
text.grabFocus();
text.selectAll();
redraw();
}
示例5: doFind
import javax.swing.JTextField; //导入方法依赖的package包/类
/** This method performs Edit->Find. */
private Runner doFind() {
if (wrap) return wrapMe();
JTextField x = OurUtil.textfield(lastFind,30);
x.selectAll();
JCheckBox c = new JCheckBox("Case Sensitive?",lastFindCaseSensitive);
c.setMnemonic('c');
JCheckBox b = new JCheckBox("Search Backward?",!lastFindForward);
b.setMnemonic('b');
if (!OurDialog.getInput("Find", "Text:", x, " ", c, b)) return null;
if (x.getText().length() == 0) return null;
lastFind = x.getText();
lastFindCaseSensitive = c.getModel().isSelected();
lastFindForward = !b.getModel().isSelected();
doFindNext();
return null;
}
示例6: focusGained
import javax.swing.JTextField; //导入方法依赖的package包/类
public void focusGained(FocusEvent focusEvent) {
if(selectOnFocusFields == null) return;
for (JTextField txt : selectOnFocusFields) {
if(focusEvent.getSource()==txt) {
txt.selectAll();
}
}
}
示例7: getTableCellEditorComponent
import javax.swing.JTextField; //导入方法依赖的package包/类
/**
* calls JTextField.selectAll() before returning it
*/
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
JTextField c = (JTextField) super.getTableCellEditorComponent(table, value, isSelected, row, column);
c.selectAll();
return c;
}
示例8: setValueAndUpdateGUI
import javax.swing.JTextField; //导入方法依赖的package包/类
private void setValueAndUpdateGUI(int val) {
JTextField tf = (JTextField) intConfig.control;
try {
intConfig.set(val);
intConfig.setFileModified();
tf.setBackground(Color.white);
}
catch (final Exception ex) {
tf.selectAll();
tf.setBackground(Color.red);
log.warning(ex.toString());
}
}
示例9: openDataWindow
import javax.swing.JTextField; //导入方法依赖的package包/类
public void openDataWindow() {
contentPane = new JPanel( new BorderLayout( 10, 10 ) );
Border emptyBorder = BorderFactory.createEmptyBorder(10, 10, 10, 10);
contentPane.setBorder( emptyBorder );
searchPane = new JPanel( new BorderLayout( 5, 5 ) );
top = new DefaultMutableTreeNode();
okButton = new JButton("OK");
okButton.addActionListener(this);
searchBar = new JTextField(20);
searchBar.setText(defaultSearchBarText);
searchBar.selectAll();
searchBar.addActionListener(this);
createNodes(top);
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
tree.addTreeSelectionListener(this);
JScrollPane treeView = new JScrollPane(tree);
contentPane.add(treeView, "Center");
contentPane.add(okButton, "South");
searchPane.add(searchLabel, "West");
searchPane.add(searchBar, "Center");
contentPane.add(searchPane, "North");
contentPane.setOpaque(true);
frame.setContentPane(contentPane);
frame.pack();
frame.setVisible(true);
}
示例10: focusGained
import javax.swing.JTextField; //导入方法依赖的package包/类
@Override
public void focusGained(FocusEvent e)
{
JTextField tf = (JTextField)e.getComponent();
tf.selectAll();
}
示例11: initGuiComponents
import javax.swing.JTextField; //导入方法依赖的package包/类
protected void initGuiComponents(){
this.getContentPane().setLayout(new BoxLayout(this.getContentPane(),
BoxLayout.Y_AXIS));
//name field
Box nameBox = Box.createHorizontalBox();
nameBox.add(Box.createHorizontalStrut(5));
nameBox.add(new JLabel("Name: "));
nameBox.add(Box.createHorizontalStrut(5));
nameField = new JTextField(30);
nameField.setMaximumSize(
new Dimension(Integer.MAX_VALUE, nameField.getPreferredSize().height));
nameField.setRequestFocusEnabled(true);
nameField.selectAll();
nameField.setVerifyInputWhenFocusTarget(false);
nameBox.add(nameField);
nameField.setToolTipText("Enter a name for the resource");
nameBox.add(Box.createHorizontalStrut(5));
nameBox.add(Box.createHorizontalGlue());
this.getContentPane().add(nameBox);
this.getContentPane().add(Box.createVerticalStrut(5));
//parameters table
parametersEditor = new ResourceParametersEditor();
tableScroll = new JScrollPane(parametersEditor);
this.getContentPane().add(tableScroll);
this.getContentPane().add(Box.createVerticalStrut(5));
this.getContentPane().add(Box.createVerticalGlue());
//buttons box
JPanel buttonsBox = new JPanel();
buttonsBox.setLayout(new BoxLayout(buttonsBox, BoxLayout.X_AXIS));
buttonsBox.add(Box.createHorizontalStrut(10));
buttonsBox.add(okBtn = new JButton("OK"));
buttonsBox.add(Box.createHorizontalStrut(10));
buttonsBox.add(cancelBtn = new JButton("Cancel"));
buttonsBox.add(Box.createHorizontalStrut(10));
buttonsBox.add(helpBtn = new JButton("Help"));
buttonsBox.add(Box.createHorizontalStrut(10));
this.getContentPane().add(buttonsBox);
this.getContentPane().add(Box.createVerticalStrut(5));
setSize(400, 300);
getRootPane().setDefaultButton(okBtn);
}
示例12: AccessAllData
import javax.swing.JTextField; //导入方法依赖的package包/类
public AccessAllData( haxby.map.MapApp owner , boolean parseLayers) {
this.parseLayers = parseLayers;
mapApp = owner;
switch (mapApp.getMapType()) {
default:
case MapApp.MERCATOR_MAP: layersXMLName = "layers.xml"; break;
case MapApp.SOUTH_POLAR_MAP: layersXMLName = "layers_SP.xml"; break;
case MapApp.NORTH_POLAR_MAP: layersXMLName = "layers_NP.xml"; break;
}
openTreePaths = new Vector();
layerNameToURL = new Hashtable();
globalNameToURL = new Hashtable();
globalNameToType = new Hashtable();
focusNameToURL = new Hashtable();
focusNameToType = new Hashtable();
focusNameToWFSLayer = new Hashtable();
rootVector = new Vector();
frame = new JFrame("Available Data");
contentPane = new JPanel( new BorderLayout( 10, 10 ) );
Border emptyBorder = BorderFactory.createEmptyBorder(10, 10, 10, 10);
contentPane.setBorder( emptyBorder );
searchPane = new JPanel( new BorderLayout( 5, 5 ) );
top = new DefaultMutableTreeNode();
okButton = new JButton("OK");
okButton.addActionListener(this);
searchBar = new JTextField(20);
searchBar.setText(defaultSearchBarText);
searchBar.selectAll();
searchBar.addActionListener(this);
createNodes(top);
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
tree.addTreeSelectionListener(this);
JScrollPane treeView = new JScrollPane(tree);
contentPane.add(treeView, "Center");
contentPane.add(okButton, "South");
searchPane.add(searchLabel, "West");
searchPane.add(searchBar, "Center");
contentPane.add(searchPane, "North");
contentPane.setOpaque(true);
frame.setContentPane(contentPane);
frame.pack();
traverseTree(top, treeMenu);
}
示例13: focusGained
import javax.swing.JTextField; //导入方法依赖的package包/类
@Override
public void focusGained(FocusEvent e) {
JTextField tf = (JTextField)e.getComponent();
tf.selectAll();
}
示例14: tryDispatchingKeystrokes
import javax.swing.JTextField; //导入方法依赖的package包/类
private static boolean tryDispatchingKeystrokes(final JTextField j) throws Exception {
requestFocus(j);
j.selectAll();
sleep();
pressKey(j, KeyEvent.VK_SHIFT);
typeString("HELLO", j);
releaseKey(j, KeyEvent.VK_SHIFT);
System.err.println("Text area text is now " + j.getText());
return "HELLO".equals(j.getText());
}