Search in sources :

Example 36 with TextField

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

the class Transfer method actionPerformed.

/**
     * Method declaration
     *
     *
     * @param ev
     */
public void actionPerformed(ActionEvent ev) {
    if (ev.getSource() instanceof TextField) {
        saveTable();
        return;
    }
    String s = ev.getActionCommand();
    MenuItem i = new MenuItem();
    if (s == null) {
        if (ev.getSource() instanceof MenuItem) {
            i = (MenuItem) ev.getSource();
            s = i.getLabel();
        }
    }
    if (s == null) {
    }
    if (s.equals("Start Transfer") || s.equals("ReStart Transfer")) {
        bStart.setLabel("ReStart Transfer");
        bStart.invalidate();
        CurrentTransfer = 0;
        CurrentAlter = 0;
        transfer();
    } else if (s.equals("Continue Transfer")) {
        transfer();
    } else if (s.equals("Start Dump") || s.equals("Start Restore")) {
        CurrentTransfer = 0;
        CurrentAlter = 0;
        transfer();
    } else if (s.equals("Quit")) {
        exit();
    } else if (s.indexOf("Select Schema") >= 0) {
        String[] selection = lTable.getSelectedItems();
        if ((selection == null) || (selection.length == 0)) {
            return;
        }
        if (iSelectionStep == Transfer.SELECT_SOURCE_SCHEMA) {
            sSourceSchemas = selection;
        } else {
            sDestSchema = selection[0];
        }
        if (iTransferMode == TRFM_DUMP) {
            iSelectionStep = Transfer.SELECT_SOURCE_TABLES;
        } else {
            iSelectionStep++;
        }
        ProcessNextStep();
    } else if (s.indexOf("Select Catalog") >= 0) {
        String selection = lTable.getSelectedItem();
        if ((selection == null) || (selection.equals(""))) {
            return;
        }
        if (iSelectionStep == Transfer.SELECT_SOURCE_CATALOG) {
            sSourceCatalog = selection;
            sSourceSchemas = null;
        } else {
            sDestCatalog = selection;
            sDestSchema = null;
            try {
                targetDb.setCatalog(sDestCatalog);
            } catch (Exception ex) {
                trace("Catalog " + sDestCatalog + " could not be selected in the target database");
                sDestCatalog = null;
            }
        }
        iSelectionStep++;
        ProcessNextStep();
    } else if (s.equals("Insert 10 rows only")) {
        iMaxRows = 10;
    } else if (s.equals("Insert 1000 rows only")) {
        iMaxRows = 1000;
    } else if (s.equals("Insert all rows")) {
        iMaxRows = 0;
    } else if (s.equals("Load Settings...")) {
        FileDialog f = new FileDialog(fMain, "Load Settings", FileDialog.LOAD);
        f.show();
        String file = f.getDirectory() + f.getFile();
        if (file != null) {
            LoadPrefs(file);
            displayTable(tCurrent);
        }
    } else if (s.equals("Save Settings...")) {
        FileDialog f = new FileDialog(fMain, "Save Settings", FileDialog.SAVE);
        f.show();
        String file = f.getDirectory() + f.getFile();
        if (file != null) {
            SavePrefs(file);
        }
    } else if (s.equals("Exit")) {
        windowClosing(null);
    }
}
Also used : TextField(java.awt.TextField) MenuItem(java.awt.MenuItem) FileDialog(java.awt.FileDialog)

Example 37 with TextField

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

the class Transfer method initGUI.

/**
     * Method declaration
     *
     */
private void initGUI() {
    Font fFont = new Font("Dialog", Font.PLAIN, 12);
    setLayout(new BorderLayout());
    Panel p = new Panel();
    p.setBackground(SystemColor.control);
    p.setLayout(new GridLayout(16, 1));
    tSourceTable = new TextField();
    tSourceTable.setEnabled(false);
    tDestTable = new TextField();
    tDestTable.addActionListener(this);
    tDestDrop = new TextField();
    tDestDrop.addActionListener(this);
    tDestCreate = new TextField();
    tDestCreate.addActionListener(this);
    tDestDelete = new TextField();
    tDestDelete.addActionListener(this);
    tDestCreateIndex = new TextField();
    tDestCreateIndex.addActionListener(this);
    tDestDropIndex = new TextField();
    tDestDropIndex.addActionListener(this);
    tSourceSelect = new TextField();
    tSourceSelect.addActionListener(this);
    tDestInsert = new TextField();
    tDestInsert.addActionListener(this);
    tDestAlter = new TextField();
    tDestAlter.addActionListener(this);
    cTransfer = new Checkbox("Transfer to destination table", true);
    cTransfer.addItemListener(this);
    cDrop = new Checkbox("Drop destination table (ignore error)", true);
    cDrop.addItemListener(this);
    cCreate = new Checkbox("Create destination table", true);
    cCreate.addItemListener(this);
    cDropIndex = new Checkbox("Drop destination index (ignore error)", true);
    cDropIndex.addItemListener(this);
    cIdxForced = new Checkbox("force Idx_ prefix for indexes names", false);
    cIdxForced.addItemListener(this);
    cCreateIndex = new Checkbox("Create destination index", true);
    cCreateIndex.addItemListener(this);
    cDelete = new Checkbox("Delete rows in destination table", true);
    cDelete.addItemListener(this);
    cInsert = new Checkbox("Insert into destination", true);
    cInsert.addItemListener(this);
    cFKForced = new Checkbox("force FK_ prefix for foreign key names", false);
    cFKForced.addItemListener(this);
    cAlter = new Checkbox("Alter destination table", true);
    cAlter.addItemListener(this);
    p.add(createLabel("Source table"));
    p.add(tSourceTable);
    p.add(cTransfer);
    p.add(tDestTable);
    p.add(cDrop);
    p.add(tDestDrop);
    p.add(cCreate);
    p.add(tDestCreate);
    p.add(cDropIndex);
    p.add(tDestDropIndex);
    p.add(cCreateIndex);
    p.add(tDestCreateIndex);
    p.add(cDelete);
    p.add(tDestDelete);
    p.add(cAlter);
    p.add(tDestAlter);
    p.add(createLabel("Select source records"));
    p.add(tSourceSelect);
    p.add(cInsert);
    p.add(tDestInsert);
    p.add(createLabel(""));
    p.add(createLabel(""));
    p.add(cIdxForced);
    p.add(cFKForced);
    p.add(createLabel(""));
    p.add(createLabel(""));
    if (iTransferMode == TRFM_TRANSFER) {
        bStart = new Button("Start Transfer");
        bContinue = new Button("Continue Transfer");
        bContinue.setEnabled(false);
    } else if (iTransferMode == Transfer.TRFM_DUMP) {
        bStart = new Button("Start Dump");
    } else if (iTransferMode == Transfer.TRFM_RESTORE) {
        bStart = new Button("Start Restore");
    }
    bStart.addActionListener(this);
    p.add(bStart);
    if (iTransferMode == TRFM_TRANSFER) {
        bContinue.addActionListener(this);
        p.add(bContinue);
    }
    bStart.setEnabled(false);
    fMain.add("Center", createBorderPanel(p));
    lTable = new java.awt.List(10);
    lTable.addItemListener(this);
    fMain.add("West", createBorderPanel(lTable));
    tMessage = new TextField();
    Panel pMessage = createBorderPanel(tMessage);
    fMain.add("South", pMessage);
}
Also used : Panel(java.awt.Panel) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) Button(java.awt.Button) Checkbox(java.awt.Checkbox) TextField(java.awt.TextField) Font(java.awt.Font)

Example 38 with TextField

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

the class TestDispose method testDispose.

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();
}
Also used : FlowLayout(java.awt.FlowLayout) JFrame(javax.swing.JFrame) SunToolkit(sun.awt.SunToolkit) TextField(java.awt.TextField)

Example 39 with TextField

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

the class SelectionInvisibleTest method main.

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

Example 40 with TextField

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

the class DeadKeySystemAssertionDialog method main.

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

Aggregations

TextField (java.awt.TextField)56 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