java.awt.TextField Java Examples
The following examples show how to use
java.awt.TextField.
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: GenericDialogPlus.java From ij-ridgedetection with GNU General Public License v2.0 | 6 votes |
/** * Adds the directory field. * * @param label * the label * @param defaultPath * the default path * @param columns * the columns */ public void addDirectoryField(String label, String defaultPath, int columns) { addStringField(label, defaultPath, columns); if (isHeadless()) return; TextField text = (TextField) stringField.lastElement(); GridBagLayout layout = (GridBagLayout) getLayout(); GridBagConstraints constraints = layout.getConstraints(text); Button button = new Button("Browse..."); DirectoryListener listener = new DirectoryListener("Browse for " + label, text); button.addActionListener(listener); button.addKeyListener(this); Panel panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); panel.add(text); panel.add(button); layout.setConstraints(panel, constraints); add(panel); }
Example #2
Source File: DeadKeySystemAssertionDialog.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Frame frame = new Frame(); frame.setSize(300, 200); TextField textField = new TextField(); frame.add(textField); frame.setVisible(true); toolkit.realSync(); textField.requestFocus(); toolkit.realSync(); // Check that the system assertion dialog does not block Java Robot robot = new Robot(); robot.setAutoDelay(50); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); toolkit.realSync(); frame.setVisible(false); frame.dispose(); }
Example #3
Source File: SelectionVisible.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example #4
Source File: DeadKeySystemAssertionDialog.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Frame frame = new Frame(); frame.setSize(300, 200); TextField textField = new TextField(); frame.add(textField); frame.setVisible(true); toolkit.realSync(); textField.requestFocus(); toolkit.realSync(); // Check that the system assertion dialog does not block Java Robot robot = new Robot(); robot.setAutoDelay(50); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); toolkit.realSync(); frame.setVisible(false); frame.dispose(); }
Example #5
Source File: MultiResolutionSplashTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
static void testFocus() throws Exception { Robot robot = new Robot(); robot.setAutoDelay(50); Frame frame = new Frame(); frame.setSize(100, 100); String test = "123"; TextField textField = new TextField(test); textField.selectAll(); frame.add(textField); frame.setVisible(true); robot.waitForIdle(); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); robot.keyPress(KeyEvent.VK_B); robot.keyRelease(KeyEvent.VK_B); robot.waitForIdle(); frame.dispose(); if (!textField.getText().equals("ab")) { throw new RuntimeException("Focus is lost!"); } }
Example #6
Source File: StringRequester.java From pdfxtk with Apache License 2.0 | 6 votes |
public StringRequester(Frame parent, String title, String lines, String posText_, String negText) { super(parent, title, true); setLayout(new GridBagLayout()); posText = posText_; add(new MultiLineLabel(lines), Awt.constraints(true)); text = new TextField(30); add(text, Awt.constraints(true, 10, 4, GridBagConstraints.HORIZONTAL)); Button pos = new Button(posText); add(pos, Awt.constraints(false, 10, 4, GridBagConstraints.HORIZONTAL)); pos.addActionListener(this); Button neg = new Button(negText); add(neg, Awt.constraints(true, 10, 4, GridBagConstraints.HORIZONTAL)); neg.addActionListener(this); pack(); }
Example #7
Source File: FocusTransitionTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void createAndShowGUI() { frame = new Frame("Test Frame"); textField1 = new TextField(5); button = new Button("Go"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textField1.requestFocusInWindow(); startUpdate(); } }); frame.setLayout(new FlowLayout()); frame.setSize(400, 200); frame.add(textField1); frame.add(new TextField(5)); frame.add(new TextField(5)); frame.add(button); frame.setVisible(true); }
Example #8
Source File: MultiResolutionSplashTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
static void testFocus() throws Exception { System.out.println("Focus Test!"); Robot robot = new Robot(); robot.setAutoDelay(50); Frame frame = new Frame(); frame.setSize(100, 100); String test = "123"; TextField textField = new TextField(test); frame.add(textField); frame.setVisible(true); robot.waitForIdle(); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); robot.keyPress(KeyEvent.VK_B); robot.keyRelease(KeyEvent.VK_B); robot.waitForIdle(); frame.dispose(); if(!textField.getText().equals("ab")){ throw new RuntimeException("Focus is lost!"); } }
Example #9
Source File: PluginHelper.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
public static void addSaveAsFileField( final GenericDialogPlus dialog, final String label, final String defaultPath, final int columns) { dialog.addStringField( label, defaultPath, columns ); final TextField text = ( TextField ) dialog.getStringFields().lastElement(); final GridBagLayout layout = ( GridBagLayout ) dialog.getLayout(); final GridBagConstraints constraints = layout.getConstraints( text ); final Button button = new Button( "Browse..." ); final ChooseXmlFileListener listener = new ChooseXmlFileListener( text ); button.addActionListener( listener ); button.addKeyListener( dialog ); final Panel panel = new Panel(); panel.setLayout( new FlowLayout( FlowLayout.LEFT, 0, 0 ) ); panel.add( text ); panel.add( button ); layout.setConstraints( panel, constraints ); dialog.add( panel ); }
Example #10
Source File: DeadKeySystemAssertionDialog.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Frame frame = new Frame(); frame.setSize(300, 200); TextField textField = new TextField(); frame.add(textField); frame.setVisible(true); toolkit.realSync(); textField.requestFocus(); toolkit.realSync(); // Check that the system assertion dialog does not block Java Robot robot = new Robot(); robot.setAutoDelay(50); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); toolkit.realSync(); frame.setVisible(false); frame.dispose(); }
Example #11
Source File: SelectionVisible.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example #12
Source File: SelectionVisible.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example #13
Source File: DeadKeySystemAssertionDialog.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Frame frame = new Frame(); frame.setSize(300, 200); TextField textField = new TextField(); frame.add(textField); frame.setVisible(true); toolkit.realSync(); textField.requestFocus(); toolkit.realSync(); // Check that the system assertion dialog does not block Java Robot robot = new Robot(); robot.setAutoDelay(50); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); toolkit.realSync(); frame.setVisible(false); frame.dispose(); }
Example #14
Source File: SelectionVisible.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example #15
Source File: MultiResolutionSplashTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static void testFocus() throws Exception { System.out.println("Focus Test!"); Robot robot = new Robot(); robot.setAutoDelay(50); Frame frame = new Frame(); frame.setSize(100, 100); String test = "123"; TextField textField = new TextField(test); frame.add(textField); frame.setVisible(true); robot.waitForIdle(); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); robot.keyPress(KeyEvent.VK_B); robot.keyRelease(KeyEvent.VK_B); robot.waitForIdle(); frame.dispose(); if(!textField.getText().equals("ab")){ throw new RuntimeException("Focus is lost!"); } }
Example #16
Source File: DeadKeySystemAssertionDialog.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Frame frame = new Frame(); frame.setSize(300, 200); TextField textField = new TextField(); frame.add(textField); frame.setVisible(true); toolkit.realSync(); textField.requestFocus(); toolkit.realSync(); // Check that the system assertion dialog does not block Java Robot robot = new Robot(); robot.setAutoDelay(50); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); toolkit.realSync(); frame.setVisible(false); frame.dispose(); }
Example #17
Source File: SelectionVisible.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example #18
Source File: SelectionVisible.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example #19
Source File: DeadKeySystemAssertionDialog.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Frame frame = new Frame(); frame.setSize(300, 200); TextField textField = new TextField(); frame.add(textField); frame.setVisible(true); toolkit.realSync(); textField.requestFocus(); toolkit.realSync(); // Check that the system assertion dialog does not block Java Robot robot = new Robot(); robot.setAutoDelay(50); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); toolkit.realSync(); frame.setVisible(false); frame.dispose(); }
Example #20
Source File: DeadKeySystemAssertionDialog.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Frame frame = new Frame(); frame.setSize(300, 200); TextField textField = new TextField(); frame.add(textField); frame.setVisible(true); toolkit.realSync(); textField.requestFocus(); toolkit.realSync(); // Check that the system assertion dialog does not block Java Robot robot = new Robot(); robot.setAutoDelay(50); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); toolkit.realSync(); frame.setVisible(false); frame.dispose(); }
Example #21
Source File: ScrollSelectionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void initTestWindow() { mainFrame = new Frame("ScrollSelectionTest frame"); mainFrame.setBounds(500, 0, 400, 200); textField = new TextField(40); textField.setText("abcdefghijklmnopqrstuvwxyz"); mainFrame.add(textField); mainFrame.setLayout(new FlowLayout()); textField.select(0, 20); mainFrame.setVisible(true); }
Example #22
Source File: TextInput.java From openbd-core with GNU General Public License v3.0 | 5 votes |
public TextInput(String _formName, String _objectName, Applet _parent){ field = new TextField(); setBackCol( Color.white ); win = JSObject.getWindow(_parent); field.addKeyListener( this ); formName = _formName; objectName = _objectName; }
Example #23
Source File: CpnZoomScreen.java From jmg with GNU General Public License v2.0 | 5 votes |
private static int getIntegerValue( TextField theField ) { StringTokenizer fieldTokenizer = new StringTokenizer(theField.getText()); String fieldString = fieldTokenizer.nextToken(); return new Integer(fieldString).intValue(); }
Example #24
Source File: TestDispose.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public void testDispose() throws InvocationTargetException, InterruptedException { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame = new JFrame("Test"); textField = new TextField("editable textArea"); textField.setEditable(true); // textField.setEditable(false); // this testcase passes if textField is non-editable frame.setLayout(new FlowLayout()); frame.add(textField); frame.pack(); frame.setVisible(true); } }); toolkit.realSync(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame.dispose(); } }); toolkit.realSync(); }
Example #25
Source File: TestDispose.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public void testDispose() throws InvocationTargetException, InterruptedException { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame = new JFrame("Test"); textField = new TextField("editable textArea"); textField.setEditable(true); // textField.setEditable(false); // this testcase passes if textField is non-editable frame.setLayout(new FlowLayout()); frame.add(textField); frame.pack(); frame.setVisible(true); } }); toolkit.realSync(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame.dispose(); } }); toolkit.realSync(); }
Example #26
Source File: TextFieldBeanInfo.java From netbeans with Apache License 2.0 | 5 votes |
/** @return Propertydescriptors */ @Override public PropertyDescriptor[] createPDs() throws IntrospectionException { return new PropertyDescriptor[] { new PropertyDescriptor("columns", TextField.class), // NOI18N new PropertyDescriptor("echoChar", TextField.class), // NOI18N }; }
Example #27
Source File: SelectionInvisibleTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Frame frame = new Frame(); frame.setSize(300, 200); TextField textField = new TextField(TEXT + LAST_WORD, 30); Panel panel = new Panel(new FlowLayout()); panel.add(textField); frame.add(panel); frame.setVisible(true); SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); toolkit.realSync(); Robot robot = new Robot(); robot.setAutoDelay(50); Point point = textField.getLocationOnScreen(); int x = point.x + textField.getWidth() / 2; int y = point.y + textField.getHeight() / 2; robot.mouseMove(x, y); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); toolkit.realSync(); robot.mousePress(InputEvent.BUTTON1_MASK); int N = 10; int dx = textField.getWidth() / N; for (int i = 0; i < N; i++) { x += dx; robot.mouseMove(x, y); } robot.mouseRelease(InputEvent.BUTTON1_MASK); toolkit.realSync(); if (!textField.getSelectedText().endsWith(LAST_WORD)) { throw new RuntimeException("Last word is not selected!"); } }
Example #28
Source File: MultiResolutionSplashTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static void testFocus() throws Exception { System.out.println("Focus Test!"); Robot robot = new Robot(); robot.setAutoDelay(50); Frame frame = new Frame(); frame.setSize(100, 100); String test = "123"; TextField textField = new TextField(test); textField.selectAll(); frame.add(textField); frame.setVisible(true); robot.waitForIdle(); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); robot.keyPress(KeyEvent.VK_B); robot.keyRelease(KeyEvent.VK_B); robot.waitForIdle(); frame.dispose(); if(!textField.getText().equals("ab")){ throw new RuntimeException("Focus is lost!"); } }
Example #29
Source File: TestDispose.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void testDispose() throws InvocationTargetException, InterruptedException { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame = new JFrame("Test"); textField = new TextField("editable textArea"); textField.setEditable(true); // textField.setEditable(false); // this testcase passes if textField is non-editable frame.setLayout(new FlowLayout()); frame.add(textField); frame.pack(); frame.setVisible(true); } }); toolkit.realSync(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame.dispose(); } }); toolkit.realSync(); }
Example #30
Source File: AutomaticBoundingBox.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
protected void addListeners( final GenericDialog gd, final Vector<?> tf, final Label label, final long[] dim ) { final TextField downsample = (TextField)tf.get( 2 ); downsample.addTextListener( new TextListener() { @Override public void textValueChanged(TextEvent arg0) { int downsampling = Integer.parseInt( downsample.getText() ); final long numPixels = numPixels( dim, downsampling ); final long megabytes = (numPixels * 4) / (1024*1024); label.setText( "Image size for segmentation: " + (dim[ 0 ])/downsampling + " x " + (dim[ 1 ])/downsampling + " x " + (dim[ 2 ])/downsampling + " pixels, " + megabytes + " MB" ); label.setForeground( GUIHelper.good ); } } ); }