Search in sources :

Example 1 with TextField

use of java.awt.TextField in project voltdb by VoltDB.

the class ZaurusEditor method initGUI.

private void initGUI() {
    // without connection there are no tables
    // vAllTables is a local variable with all table names in the database
    // vHoldTableNames holds the table names which have a ZaurusTableForm
    Vector vAllTables = getAllTables();
    if (vAllTables == null) {
        return;
    }
    // initialize a new list for the table names which have a form in pForm
    vHoldTableNames = new Vector(20);
    vHoldForms = new Vector(20);
    // this holds the card panel pForm for the forms in the top
    // a card panel pButton below
    // the both card panels form a panel which is centered in this
    // and a status line in the south
    this.setLayout(new BorderLayout(3, 3));
    // >>> the top of this: the entry forms in pForm
    // pFormButs holds in the center the forms card panel pForm and
    // in the south the button card panel pButton
    Panel pFormButs = new Panel();
    pFormButs.setLayout(new BorderLayout(3, 3));
    pForm = new Panel();
    lForm = new CardLayout(2, 2);
    pForm.setLayout(lForm);
    // the search panel containing the list of all tables and
    // the entry fields for search words in the Center
    Panel pEntry = new Panel();
    pEntry.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(3, 3, 3, 3);
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = c.weighty = 1;
    c.anchor = GridBagConstraints.WEST;
    c.gridy = 0;
    c.gridx = 0;
    pEntry.add(new Label("Search table"), c);
    c.gridx = 1;
    // get all table names and show a drop down list of them in cTables
    cTables = new Choice();
    for (Enumeration e = vAllTables.elements(); e.hasMoreElements(); ) {
        cTables.addItem((String) e.nextElement());
    }
    c.gridwidth = 2;
    pEntry.add(cTables, c);
    c.gridy = 1;
    c.gridx = 0;
    c.gridwidth = 1;
    pEntry.add(new Label("Search words"), c);
    c.gridx = 1;
    c.gridwidth = 2;
    fSearchWords = new TextField(8);
    pEntry.add(fSearchWords, c);
    // use search words
    c.gridwidth = 1;
    c.gridy = 2;
    c.gridx = 0;
    pEntry.add(new Label("Use search words"), c);
    gAllWords = new CheckboxGroup();
    Checkbox[] checkboxes = new Checkbox[2];
    checkboxes[0] = new Checkbox("all", gAllWords, true);
    c.gridx = 1;
    pEntry.add(checkboxes[0], c);
    checkboxes[1] = new Checkbox("any ", gAllWords, false);
    c.gridx = 2;
    pEntry.add(checkboxes[1], c);
    // ignore case
    c.gridy = 3;
    c.gridx = 0;
    pEntry.add(new Label("Ignore case"), c);
    gIgnoreCase = new CheckboxGroup();
    Checkbox[] checkboxes1 = new Checkbox[2];
    checkboxes1[0] = new Checkbox("yes", gIgnoreCase, true);
    c.gridx = 1;
    pEntry.add(checkboxes1[0], c);
    checkboxes1[1] = new Checkbox("no", gIgnoreCase, false);
    c.gridx = 2;
    pEntry.add(checkboxes1[1], c);
    // Match column exactly
    c.gridy = 4;
    c.gridx = 0;
    pEntry.add(new Label("Match whole col"), c);
    gNoMatchWhole = new CheckboxGroup();
    Checkbox[] checkboxes2 = new Checkbox[2];
    checkboxes2[0] = new Checkbox("no", gNoMatchWhole, true);
    c.gridx = 1;
    pEntry.add(checkboxes2[0], c);
    checkboxes2[1] = new Checkbox("yes ", gNoMatchWhole, false);
    c.gridx = 2;
    pEntry.add(checkboxes2[1], c);
    pForm.add("search", pEntry);
    pFormButs.add("Center", pForm);
    // the buttons
    this.initButtons();
    pButton = new Panel();
    lButton = new CardLayout(2, 2);
    pButton.setLayout(lButton);
    pButton.add("search", pSearchButs);
    pButton.add("edit", pEditButs);
    pButton.add("insert", pInsertButs);
    pFormButs.add("South", pButton);
    this.add("Center", pFormButs);
    // >>> the South: status line at the bottom
    Font fFont = new Font("Dialog", Font.PLAIN, 10);
    ZaurusEditor.tStatus = new TextField("");
    ZaurusEditor.tStatus.setEditable(false);
    this.add("South", ZaurusEditor.tStatus);
}
Also used : CardLayout(java.awt.CardLayout) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) Choice(java.awt.Choice) Enumeration(java.util.Enumeration) GridBagLayout(java.awt.GridBagLayout) CheckboxGroup(java.awt.CheckboxGroup) Label(java.awt.Label) Font(java.awt.Font) Panel(java.awt.Panel) BorderLayout(java.awt.BorderLayout) Checkbox(java.awt.Checkbox) TextField(java.awt.TextField) Vector(java.util.Vector)

Example 2 with TextField

use of java.awt.TextField in project jdk8u_jdk by JetBrains.

the class MultiResolutionSplashTest method testFocus.

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!");
    }
}
Also used : Frame(java.awt.Frame) TextField(java.awt.TextField) Robot(java.awt.Robot)

Example 3 with TextField

use of java.awt.TextField in project jdk8u_jdk by JetBrains.

the class SelectionVisible method init.

@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);
}
Also used : Panel(java.awt.Panel) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) TextArea(java.awt.TextArea) TextField(java.awt.TextField) Dimension(java.awt.Dimension)

Example 4 with TextField

use of java.awt.TextField in project jdk8u_jdk by JetBrains.

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    //runTest(new JScrollBar()); --> don't test defines max and min in
    // terms of preferred
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 5 with TextField

use of java.awt.TextField in project GDSC-SMLM by aherbert.

the class FolderOpenerDialog method getNumber.

public int getNumber(Object field) {
    TextField tf = (TextField) field;
    String theText = tf.getText();
    Double d;
    try {
        d = new Double(theText);
    } catch (NumberFormatException e) {
        d = null;
    }
    if (d != null)
        return (int) d.doubleValue();
    else
        return 0;
}
Also used : TextField(java.awt.TextField)

Aggregations

TextField (java.awt.TextField)55 Checkbox (java.awt.Checkbox)21 Choice (java.awt.Choice)21 Label (java.awt.Label)18 Panel (java.awt.Panel)17 Button (java.awt.Button)13 GenericDialog (ij.gui.GenericDialog)11 GridBagConstraints (java.awt.GridBagConstraints)11 GridBagLayout (java.awt.GridBagLayout)11 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)10 Color (java.awt.Color)9 Component (java.awt.Component)8 Vector (java.util.Vector)8 BorderLayout (java.awt.BorderLayout)6 FlowLayout (java.awt.FlowLayout)6 Dimension (java.awt.Dimension)5 Frame (java.awt.Frame)5 Insets (java.awt.Insets)5 Point (java.awt.Point)5 JPanel (javax.swing.JPanel)5