Java Code Examples for javax.swing.JTextField#requestFocusInWindow()

The following examples show how to use javax.swing.JTextField#requestFocusInWindow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImportFromAbstractDialog.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
public boolean validateUrl(JTextField field) {
    String urlStr = field.getText();
    if (urlStr.isEmpty()) {
        showWarningDialog(Constant.messages.getString(MESSAGE_PREFIX + "url.empty"));
        field.requestFocusInWindow();
        return false;
    } else if ("http://".equals(urlStr) || "https://".equals(urlStr)) {
        showWarningDialog(
                Constant.messages.getString(MESSAGE_PREFIX + "url.invalid", urlStr, ""));
        field.requestFocusInWindow();
        return false;
    }
    try {
        new URL(urlStr);
        new URI(urlStr, true);
    } catch (Exception e) {
        showWarningDialog(
                Constant.messages.getString(
                        MESSAGE_PREFIX + "url.invalid", urlStr, e.getMessage()));
        field.requestFocusInWindow();
        return false;
    }
    return true;
}
 
Example 2
Source File: ExternalSourcesViewer.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private static void insertFile(JTextField textField, File file) {
        String path = file.getAbsolutePath();
        if (path.contains(" ")) path = "\"" + path + "\"";                      // NOI18N
        
//        try { textField.getDocument().insertString(textField.getCaretPosition(), path, null); }
        try {
            textField.getDocument().insertString(0, path, null);
            textField.select(0, path.length());
            textField.requestFocusInWindow();
        } catch (BadLocationException ex) {}
    }
 
Example 3
Source File: TextComponentPopupMenu.java    From xtunnel with GNU General Public License v2.0 5 votes vote down vote up
public void mouseReleased(MouseEvent e) {
	if (e.isPopupTrigger() && e.getSource() instanceof JTextField) {
		JTextField textfield = (JTextField) e.getSource();
		if (Boolean.TRUE.equals(textfield
				.getClientProperty("DisablePopupMenu"))) {
			return;
		}
		textfield.requestFocusInWindow();
		show(textfield, e.getX(), e.getY());
	}
}
 
Example 4
Source File: SplitterFrame.java    From ios-image-util with MIT License 5 votes vote down vote up
/**
 * Set size as text to text field.
 *
 * @param text
 * @param value
 */
private void setSizeText(JTextField text, String value) {
	try {
		setImageSize(text, value);
	} catch (Throwable t) {
		t.printStackTrace();
		text.requestFocusInWindow();
	}
}
 
Example 5
Source File: DeadKeyMacOSXInputText.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();

    textField.requestFocusInWindow();
    toolkit.realSync();

}
 
Example 6
Source File: DeadKeyMacOSXInputText.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();

    textField.requestFocusInWindow();
    toolkit.realSync();

}
 
Example 7
Source File: StatTableModel.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void startEditingNextRow(final JTable statsTable, final int col, final int nextRow, JTextField textField)
{
	if (nextRow >= 0 && nextRow < getRowCount() && col >= 0 && col < getColumnCount())
	{
		statsTable.editCellAt(nextRow, col);
		textField.requestFocusInWindow();
	}
}
 
Example 8
Source File: StatTableModel.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void startEditingNextRow(final JTable statsTable, final int col, final int nextRow, JTextField textField)
{
	if (nextRow >= 0 && nextRow < getRowCount() && col >= 0 && col < getColumnCount())
	{
		statsTable.editCellAt(nextRow, col);
		textField.requestFocusInWindow();
	}
}
 
Example 9
Source File: DeadKeyMacOSXInputText.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();

    textField.requestFocusInWindow();
    toolkit.realSync();

}
 
Example 10
Source File: TextComponentPopupMenu.java    From finalspeed-91yun with GNU General Public License v2.0 5 votes vote down vote up
public void mouseReleased(MouseEvent e) {
	if (e.isPopupTrigger() && e.getSource() instanceof JTextField) {
		JTextField textfield = (JTextField) e.getSource();
		if (Boolean.TRUE.equals(textfield
				.getClientProperty("DisablePopupMenu"))) {
			return;
		}
		textfield.requestFocusInWindow();
		show(textfield, e.getX(), e.getY());
	}
}
 
Example 11
Source File: FlatSpinnerUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
public void focusGained( FocusEvent e ) {
	spinner.repaint();

	// if spinner gained focus, transfer it to the editor text field
	if( e.getComponent() == spinner ) {
		JTextField textField = getEditorTextField( spinner.getEditor() );
		if( textField != null )
			textField.requestFocusInWindow();
	}
}
 
Example 12
Source File: DeadKeyMacOSXInputText.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();

    textField.requestFocusInWindow();
    toolkit.realSync();

}
 
Example 13
Source File: DeadKeyMacOSXInputText.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();

    textField.requestFocusInWindow();
    toolkit.realSync();

}
 
Example 14
Source File: DeadKeyMacOSXInputText.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();

    textField.requestFocusInWindow();
    toolkit.realSync();

}
 
Example 15
Source File: DeadKeyMacOSXInputText.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI(Robot robot) {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    robot.waitForIdle();

    textField.requestFocusInWindow();
    robot.waitForIdle();

}
 
Example 16
Source File: DeadKeyMacOSXInputText.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();

    textField.requestFocusInWindow();
    toolkit.realSync();

}
 
Example 17
Source File: DeadKeyMacOSXInputText.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();

    textField.requestFocusInWindow();
    toolkit.realSync();

}
 
Example 18
Source File: DeadKeyMacOSXInputText.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();

    textField.requestFocusInWindow();
    toolkit.realSync();

}
 
Example 19
Source File: DeadKeyMacOSXInputText.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();

    textField.requestFocusInWindow();
    toolkit.realSync();

}
 
Example 20
Source File: DeadKeyMacOSXInputText.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void createAndShowGUI() {
    Frame frame = new Frame();
    frame.setSize(300, 300);
    Panel panel = new Panel(new BorderLayout());
    JTextField textField = new JTextField();
    textField.addKeyListener(new DeadKeyListener());
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel);
    frame.setVisible(true);
    toolkit.realSync();

    textField.requestFocusInWindow();
    toolkit.realSync();

}