本文整理了Java中javax.swing.JTextField.grabFocus()
方法的一些代码示例,展示了JTextField.grabFocus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextField.grabFocus()
方法的具体详情如下:
包路径:javax.swing.JTextField
类名称:JTextField
方法名:grabFocus
暂无
代码示例来源:origin: gocd/gocd
public void ask() {
AgentBootstrapperArgs bootstrapperArgs = agentMacWindow.getBootstrapperArgs();
this.serverTextField.setText(bootstrapperArgs.getServerUrl().toString());
this.fileBrowser.setFile(bootstrapperArgs.getRootCertFile());
this.sslModeComponent.setSslMode(bootstrapperArgs.getSslMode());
serverTextField.selectAll();
serverTextField.grabFocus();
setVisible(true);
}
代码示例来源:origin: winder/Universal-G-Code-Sender
private void opencloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opencloseButtonActionPerformed
if( this.opencloseButton.getText().equalsIgnoreCase(Localization.getString("open")) ) {
this.commandTable.clear();
this.sentRowsValueLabel.setText("0");
String firmware = this.firmwareComboBox.getSelectedItem().toString();
String port = commPortComboBox.getSelectedItem().toString();
int baudRate = Integer.parseInt(baudrateSelectionComboBox.getSelectedItem().toString());
try {
this.backend.connect(firmware, port, baudRate);
// Let the command field grab focus.
commandTextField.grabFocus();
} catch (Exception e) {
e.printStackTrace();
displayErrorDialog(e.getMessage());
}
} else {
try {
this.backend.disconnect();
} catch (Exception e) {
displayErrorDialog(e.getMessage());
}
}
}//GEN-LAST:event_opencloseButtonActionPerformed
代码示例来源:origin: openmrs/openmrs-core
@Override
public void run() {
if (frame != null) {
// bring the dialog's window to the front
frame.toFront();
usernameField.grabFocus();
}
}
};
代码示例来源:origin: openmrs/openmrs-core
@Override
public void run() {
if (frame != null) {
frame.toFront(); // bring the dialog's window to the
// front
usernameField.grabFocus();
}
}
};
代码示例来源:origin: com.github.waikato/fcms-widgets
/**
* Lets the text component grab the focus.
*/
@Override
public void grabFocus() {
m_TextSelection.grabFocus();
}
代码示例来源:origin: Waikato/meka
/**
* The text field for the search tries to grab the focus.
*/
public void grabFocus() {
m_TextSearch.grabFocus();
}
代码示例来源:origin: net.sf.meka/meka
/**
* The text field for the search tries to grab the focus.
*/
public void grabFocus() {
m_TextSearch.grabFocus();
}
代码示例来源:origin: edu.toronto.cs.savant/savant-core
private boolean parseURL() {
boolean result = false;
String urlStr = urlField.getText();
try {
url = new URL(urlStr);
result = true;
} catch (MalformedURLException e) {
Toolkit.getDefaultToolkit().beep();
urlField.grabFocus();
}
return result;
}
代码示例来源:origin: cmu-phil/tetrad
public void focusLost(FocusEvent e) {
if (alreadyLostFocus) return;
JTextField field = (JTextField) e.getSource();
field.grabFocus();
alreadyLostFocus = true;
}
});
代码示例来源:origin: cmu-phil/tetrad
public void focusLost(FocusEvent e) {
if (alreadyLostFocus) return;
JTextField field = (JTextField) e.getSource();
field.grabFocus();
alreadyLostFocus = true;
}
});
代码示例来源:origin: cmu-phil/tetrad
public void focusLost(FocusEvent e) {
if (alreadyLostFocus) return;
JTextField field = (JTextField) e.getSource();
field.grabFocus();
alreadyLostFocus = true;
}
});
代码示例来源:origin: cmu-phil/tetrad
public void focusLost(FocusEvent e) {
if (alreadyLostFocus) return;
JTextField field = (JTextField) e.getSource();
field.grabFocus();
alreadyLostFocus = true;
}
});
代码示例来源:origin: cmu-phil/tetrad
public void focusLost(FocusEvent e) {
if (alreadyLostFocus) return;
JTextField field = (JTextField) e.getSource();
field.grabFocus();
alreadyLostFocus = true;
}
});
代码示例来源:origin: stackoverflow.com
JTextField main = xa.getTextField();
main.grabFocus();
assertTrue(main.isFocusOwner());
代码示例来源:origin: cmu-phil/tetrad
/**
* Highlights the next selection.
*/
private void highlightNextSelection() {
System.out.println("Highlighting next selection.");
if (!this.selections.isEmpty()) {
Selection sel = this.selections.get(0);
this.expression.setSelectionColor(SELECTION);
this.expression.select(sel.x, sel.y);
this.expression.grabFocus();
}
}
代码示例来源:origin: org.jacorb/jacorb
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals("Ok"))
{
try
{
updateInterval=Integer.parseInt(editSeconds.getText());
isOk=true; dispose();
} catch (Exception ex)
{
JOptionPane.showMessageDialog(this,"Wrong number format",
"Input error", JOptionPane.ERROR_MESSAGE);
editSeconds.grabFocus(); editSeconds.selectAll();
}
}
else dispose();
}
public void keyPressed(KeyEvent e)
代码示例来源:origin: senbox-org/s2tbx
private void setValues(SpectrumInput spec) {
StringBuilder xElements = new StringBuilder();
StringBuilder yElements = new StringBuilder();
int length = spec.getXPixelPolygonPositions().length;
for (int index = 0; index< length-2; index++) {
xElements.append(spec.getXPixelPolygonPositions()[index]).append(",");
yElements.append(spec.getYPixelPolygonPositions()[index]).append(",");
}
xElements.append(spec.getXPixelPolygonPositions()[length - 2]);
yElements.append(spec.getYPixelPolygonPositions()[length - 2]);
xCoordinates.setText(xElements.toString());
yCoordinates.setText(yElements.toString());
spectrumClassName.grabFocus();
this.isShapeDefined = true;
}
代码示例来源:origin: omegat-org/omegat
/**
* Checks text value of JTextField if it is a valid regular expression. If not, focus is set to the text field and
* an alert is shown.
*
* @param textfield
* the text field with the regular expression
* @return true if regular expression is valid, false otherwise
*/
private boolean checkRegExp(JTextField textfield) {
try {
Pattern.compile(textfield.getText());
} catch (PatternSyntaxException e) {
textfield.setCaretPosition(e.getIndex());
JOptionPane.showMessageDialog(this,
e.getLocalizedMessage(), OStrings.getString("HTML_ERROR_CUSTOMREGEXP_TITLE"),
JOptionPane.ERROR_MESSAGE);
textfield.grabFocus();
return false;
}
return true;
}
代码示例来源:origin: omegat-org/omegat
/**
* Checks text value of JTextField if it is a valid regular expression. If not, focus is set to the text field and
* an alert is shown.
*
* @param textfield
* the text field with the regular expression
* @return true if regular expression is valid, false otherwise
*/
private boolean checkRegExp(JTextField textfield) {
try {
Pattern.compile(textfield.getText());
} catch (PatternSyntaxException e) {
textfield.setCaretPosition(e.getIndex());
JOptionPane.showMessageDialog(this,
e.getLocalizedMessage(), OStrings.getString("HTML_ERROR_CUSTOMREGEXP_TITLE"),
JOptionPane.ERROR_MESSAGE);
textfield.grabFocus();
return false;
}
return true;
}
代码示例来源:origin: com.synaptix/SynaptixWidget
private void removeValue() {
E oldValue = this.value;
this.value = null;
nameField.setText(null);
nameField.setEditable(editable && isEnabled());
nameField.setFocusable(editable && isEnabled());
if (button.hasFocus()) {
nameField.grabFocus();
}
if (toolTipFocusListener != null) {
toolTipFocusListener.setEnabled(editable && isEnabled());
}
paintNameFieldBackground();
firePropertyChange("value", oldValue, this.value);
updateRemoveLabel();
}
内容来源于网络,如有侵权,请联系作者删除!