Search in sources :

Example 1 with CheckboxGroup

use of java.awt.CheckboxGroup 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 CheckboxGroup

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

the class SetStateExcessEvent method main.

public static void main(final String[] args) throws Exception {
    final Robot robot = new Robot();
    final CheckboxGroup group = new CheckboxGroup();
    final Checkbox[] cbs = { new Checkbox("checkbox1", true, group), new Checkbox("checkbox2", false, group), new Checkbox("checkbox3", true, group), new Checkbox("checkbox4", true), new Checkbox("checkbox5", false), new Checkbox("checkbox6", true) };
    final Frame frame = new Frame();
    frame.setLayout(new GridBagLayout());
    try {
        for (final Checkbox cb : cbs) {
            cb.addItemListener(e -> {
                failed = true;
            });
        }
        for (final Checkbox cb : cbs) {
            frame.add(cb);
        }
        frame.pack();
        for (final Checkbox cb : cbs) {
            cb.setState(!cb.getState());
        }
        for (final Checkbox cb : cbs) {
            group.setSelectedCheckbox(cb);
        }
        robot.waitForIdle();
    } finally {
        frame.dispose();
    }
    if (failed) {
        throw new RuntimeException("Listener should not be called");
    }
    System.out.println("Test passed");
}
Also used : Frame(java.awt.Frame) GridBagLayout(java.awt.GridBagLayout) Checkbox(java.awt.Checkbox) CheckboxGroup(java.awt.CheckboxGroup) Robot(java.awt.Robot)

Aggregations

Checkbox (java.awt.Checkbox)2 CheckboxGroup (java.awt.CheckboxGroup)2 GridBagLayout (java.awt.GridBagLayout)2 BorderLayout (java.awt.BorderLayout)1 CardLayout (java.awt.CardLayout)1 Choice (java.awt.Choice)1 Font (java.awt.Font)1 Frame (java.awt.Frame)1 GridBagConstraints (java.awt.GridBagConstraints)1 Insets (java.awt.Insets)1 Label (java.awt.Label)1 Panel (java.awt.Panel)1 Robot (java.awt.Robot)1 TextField (java.awt.TextField)1 Enumeration (java.util.Enumeration)1 Vector (java.util.Vector)1