Java Code Examples for java.awt.Button#setEnabled()

The following examples show how to use java.awt.Button#setEnabled() . 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: bug7097771.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 2
Source File: bug7097771.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 3
Source File: bug7097771.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 4
Source File: bug7097771.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 5
Source File: bug7097771.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 6
Source File: bug7097771.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 7
Source File: bug7097771.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 8
Source File: bug7097771.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    Robot robot = new Robot();
    sleep(robot);
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep(robot);
    Util.clickOnComp(button, robot);
    sleep(robot);
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 9
Source File: bug7097771.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 10
Source File: bug7097771.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 11
Source File: bug7097771.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 12
Source File: bug7097771.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 13
Source File: bug7097771.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example 14
Source File: CycleThroughFrameTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void createAndShowInstructionFrame() {
    Button passButton = new Button("Pass");
    passButton.setEnabled(true);

    Button failButton = new Button("Fail");
    failButton.setEnabled(true);

    TextArea instructions = new TextArea(12, 70);
    instructions.setText(TEST_INSTRUCTIONS);

    instructionFrame = new Frame("Test Instructions");
    instructionFrame.add(passButton);
    instructionFrame.add(failButton);
    instructionFrame.add(instructions);
    instructionFrame.setSize(200,200);
    instructionFrame.setLayout(new FlowLayout());
    instructionFrame.pack();
    instructionFrame.setVisible(true);

    passButton.addActionListener(ae -> {
        dispose();
        testContinueFlag = false;
    });

    failButton.addActionListener(ae -> {
        dispose();
        testContinueFlag = false;
        throw new RuntimeException(FAIL_MESSAGE);
    });
}
 
Example 15
Source File: CycleThroughFrameTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void createAndShowInstructionFrame() {
    Button passButton = new Button("Pass");
    passButton.setEnabled(true);

    Button failButton = new Button("Fail");
    failButton.setEnabled(true);

    TextArea instructions = new TextArea(12, 70);
    instructions.setText(TEST_INSTRUCTIONS);

    instructionFrame = new Frame("Test Instructions");
    instructionFrame.add(passButton);
    instructionFrame.add(failButton);
    instructionFrame.add(instructions);
    instructionFrame.setSize(200,200);
    instructionFrame.setLayout(new FlowLayout());
    instructionFrame.pack();
    instructionFrame.setVisible(true);

    passButton.addActionListener(ae -> {
        dispose();
        testContinueFlag = false;
    });

    failButton.addActionListener(ae -> {
        dispose();
        testContinueFlag = false;
        throw new RuntimeException(FAIL_MESSAGE);
    });
}
 
Example 16
Source File: CycleThroughFrameTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void createAndShowInstructionFrame() {
    Button passButton = new Button("Pass");
    passButton.setEnabled(true);

    Button failButton = new Button("Fail");
    failButton.setEnabled(true);

    TextArea instructions = new TextArea(12, 70);
    instructions.setText(TEST_INSTRUCTIONS);

    instructionFrame = new Frame("Test Instructions");
    instructionFrame.add(passButton);
    instructionFrame.add(failButton);
    instructionFrame.add(instructions);
    instructionFrame.setSize(200,200);
    instructionFrame.setLayout(new FlowLayout());
    instructionFrame.pack();
    instructionFrame.setVisible(true);

    passButton.addActionListener(ae -> {
        dispose();
        testContinueFlag = false;
    });

    failButton.addActionListener(ae -> {
        dispose();
        testContinueFlag = false;
        throw new RuntimeException(FAIL_MESSAGE);
    });
}
 
Example 17
Source File: CycleThroughFrameTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void createAndShowInstructionFrame() {
    Button passButton = new Button("Pass");
    passButton.setEnabled(true);

    Button failButton = new Button("Fail");
    failButton.setEnabled(true);

    TextArea instructions = new TextArea(12, 70);
    instructions.setText(TEST_INSTRUCTIONS);

    instructionFrame = new Frame("Test Instructions");
    instructionFrame.add(passButton);
    instructionFrame.add(failButton);
    instructionFrame.add(instructions);
    instructionFrame.setSize(200,200);
    instructionFrame.setLayout(new FlowLayout());
    instructionFrame.pack();
    instructionFrame.setVisible(true);

    passButton.addActionListener(ae -> {
        dispose();
        testContinueFlag = false;
    });

    failButton.addActionListener(ae -> {
        dispose();
        testContinueFlag = false;
        throw new RuntimeException(FAIL_MESSAGE);
    });
}
 
Example 18
Source File: ActionEventTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public ActionEventTest() {
    try {
        robot = new Robot();
    } catch(AWTException e) {
        throw new RuntimeException(e.getMessage());
    }

    button = new Button("ClickMe");
    button.setEnabled(true);

    instructions = new TextArea(10, 50);
    instructions.setText(
    " This is a manual test\n" +
    " Keep the Alt, Shift & Ctrl Keys pressed &\n" +
    " Click 'ClickMe' button with left mouse button\n" +
    " Test exits automatically after mouse click.");

    add(button);
    add(instructions);
    setSize(400,400);
    setLayout(new FlowLayout());
    pack();
    setVisible(true);
    robot.waitForIdle();

    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            int md = ae.getModifiers();
            int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
                    | ActionEvent.SHIFT_MASK;

            isProgInterruption = true;
            mainThread.interrupt();
            if ((md & expectedMask) != expectedMask) {
                throw new RuntimeException("Action Event modifiers"
                    + " are not set correctly.");
            }
        }
    });
}