Search in sources :

Example 11 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 12 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 13 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)

Example 14 with TextField

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

the class ConnectionDialog method create.

private void create() {
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    setLayout(new BorderLayout());
    Panel p = new Panel(new BorderLayout());
    Panel pLabel;
    Panel pText;
    Panel pButton;
    Panel pClearButton;
    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
        pLabel = new Panel(new GridLayout(8, 1, 10, 10));
        pText = new Panel(new GridLayout(8, 1, 10, 10));
        pButton = new Panel(new GridLayout(1, 2, 10, 10));
        pClearButton = new Panel(new GridLayout(8, 1, 10, 10));
    } else {
        pLabel = new Panel(new GridLayout(8, 1));
        pText = new Panel(new GridLayout(8, 1));
        pButton = new Panel(new GridLayout(1, 2));
        pClearButton = new Panel(new GridLayout(8, 1));
    }
    p.add("West", pLabel);
    p.add("Center", pText);
    p.add("South", pButton);
    p.add("North", createLabel(""));
    p.add("East", pClearButton);
    p.setBackground(SystemColor.control);
    pText.setBackground(SystemColor.control);
    pLabel.setBackground(SystemColor.control);
    pButton.setBackground(SystemColor.control);
    pLabel.add(createLabel("Recent:"));
    recent = new Choice();
    try {
        settings = ConnectionDialogCommon.loadRecentConnectionSettings();
    } catch (java.io.IOException ioe) {
        ioe.printStackTrace();
    }
    recent.add(ConnectionDialogCommon.emptySettingName);
    Enumeration en = settings.elements();
    while (en.hasMoreElements()) {
        recent.add(((ConnectionSetting) en.nextElement()).getName());
    }
    recent.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            String s = (String) e.getItem();
            ConnectionSetting setting = (ConnectionSetting) settings.get(s);
            if (setting != null) {
                mName.setText(setting.getName());
                mDriver.setText(setting.getDriver());
                mURL.setText(setting.getUrl());
                mUser.setText(setting.getUser());
                mPassword.setText(setting.getPassword());
            }
        }
    });
    pText.add(recent);
    Button b;
    b = new Button("Clr");
    b.setActionCommand("Clear");
    b.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            ConnectionDialogCommon.deleteRecentConnectionSettings();
            settings = new Hashtable();
            recent.removeAll();
            recent.add(ConnectionDialogCommon.emptySettingName);
            mName.setText(null);
        }
    });
    pClearButton.add(b);
    pLabel.add(createLabel("Setting Name:"));
    mName = new TextField("");
    pText.add(mName);
    pLabel.add(createLabel("Type:"));
    types = new Choice();
    connTypes = ConnectionDialogCommon.getTypes();
    for (int i = 0; i < connTypes.length; i++) {
        types.add(connTypes[i][0]);
    }
    types.addItemListener(this);
    pText.add(types);
    pLabel.add(createLabel("Driver:"));
    mDriver = new TextField(connTypes[0][1]);
    pText.add(mDriver);
    pLabel.add(createLabel("URL:"));
    mURL = new TextField(connTypes[0][2]);
    mURL.addActionListener(this);
    pText.add(mURL);
    pLabel.add(createLabel("User:"));
    mUser = new TextField("SA");
    mUser.addActionListener(this);
    pText.add(mUser);
    pLabel.add(createLabel("Password:"));
    mPassword = new TextField("");
    mPassword.addActionListener(this);
    mPassword.setEchoChar('*');
    pText.add(mPassword);
    b = new Button("Ok");
    b.setActionCommand("ConnectOk");
    b.addActionListener(this);
    pButton.add(b);
    b = new Button("Cancel");
    b.setActionCommand("ConnectCancel");
    b.addActionListener(this);
    pButton.add(b);
    add("East", createLabel(""));
    add("West", createLabel(""));
    mError = new Label("");
    Panel pMessage = createBorderPanel(mError);
    add("South", pMessage);
    add("North", createLabel(""));
    add("Center", p);
    doLayout();
    pack();
    Dimension size = getSize();
    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
        setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else {
        setLocation(0, 0);
        setSize(d);
    }
    show();
}
Also used : ItemEvent(java.awt.event.ItemEvent) Choice(java.awt.Choice) Enumeration(java.util.Enumeration) ActionEvent(java.awt.event.ActionEvent) Hashtable(java.util.Hashtable) Label(java.awt.Label) Dimension(java.awt.Dimension) Panel(java.awt.Panel) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) Button(java.awt.Button) TextField(java.awt.TextField) ItemListener(java.awt.event.ItemListener)

Example 15 with TextField

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

the class ZaurusConnectionDialog method create.

/**
     * Method declaration
     *
     */
void create(Insets defInsets) {
    setLayout(new BorderLayout());
    addKeyListener(this);
    Panel p = new Panel(new GridLayout(6, 2, 10, 10));
    p.addKeyListener(this);
    p.setBackground(SystemColor.control);
    p.add(createLabel("Type:"));
    Choice types = new Choice();
    types.addItemListener(this);
    types.addKeyListener(this);
    for (int i = 0; i < sJDBCTypes.length; i++) {
        types.add(sJDBCTypes[i][0]);
    }
    p.add(types);
    p.add(createLabel("Driver:"));
    mDriver = new TextField("org.hsqldb_voltpatches.jdbcDriver");
    mDriver.addKeyListener(this);
    p.add(mDriver);
    p.add(createLabel("URL:"));
    mURL = new TextField("jdbc:hsqldb:mem:.");
    mURL.addKeyListener(this);
    p.add(mURL);
    p.add(createLabel("User:"));
    mUser = new TextField("SA");
    mUser.addKeyListener(this);
    p.add(mUser);
    p.add(createLabel("Password:"));
    mPassword = new TextField("");
    mPassword.addKeyListener(this);
    mPassword.setEchoChar('*');
    p.add(mPassword);
    Button b;
    b = new Button("Cancel");
    b.setActionCommand("ConnectCancel");
    b.addActionListener(this);
    b.addKeyListener(this);
    p.add(b);
    b = new Button("Ok");
    b.setActionCommand("ConnectOk");
    b.addActionListener(this);
    b.addKeyListener(this);
    p.add(b);
    setLayout(new BorderLayout());
    add("East", createLabel(" "));
    add("West", createLabel(" "));
    mError = new Label("");
    Panel pMessage = createBorderPanel(mError);
    pMessage.addKeyListener(this);
    add("South", pMessage);
    add("North", createLabel(""));
    add("Center", p);
    doLayout();
    pack();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = getSize();
    if (d.width > 640) {
        setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else if (defInsets.top > 0 && defInsets.left > 0) {
        setLocation(defInsets.bottom, defInsets.right);
        setSize(defInsets.top, defInsets.left);
    // full size on screen with less than 640 width
    } else {
        setLocation(0, 0);
        setSize(d);
    }
    show();
}
Also used : Panel(java.awt.Panel) GridLayout(java.awt.GridLayout) Choice(java.awt.Choice) BorderLayout(java.awt.BorderLayout) Button(java.awt.Button) Label(java.awt.Label) TextField(java.awt.TextField) Dimension(java.awt.Dimension)

Aggregations

TextField (java.awt.TextField)24 Choice (java.awt.Choice)10 Checkbox (java.awt.Checkbox)9 Panel (java.awt.Panel)8 Vector (java.util.Vector)7 GenericDialog (ij.gui.GenericDialog)6 Label (java.awt.Label)6 BorderLayout (java.awt.BorderLayout)5 Button (java.awt.Button)5 GlobalSettings (gdsc.smlm.ij.settings.GlobalSettings)4 Component (java.awt.Component)4 FlowLayout (java.awt.FlowLayout)4 Frame (java.awt.Frame)4 GridBagConstraints (java.awt.GridBagConstraints)4 GridBagLayout (java.awt.GridBagLayout)4 BasePoint (gdsc.core.match.BasePoint)3 PeakResultPoint (gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint)3 Dimension (java.awt.Dimension)3 GridLayout (java.awt.GridLayout)3 Robot (java.awt.Robot)3