本文整理匯總了Java中java.awt.Button.setEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java Button.setEnabled方法的具體用法?Java Button.setEnabled怎麽用?Java Button.setEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Button
的用法示例。
在下文中一共展示了Button.setEnabled方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import java.awt.Button; //導入方法依賴的package包/類
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.");
}
}
示例2: main
import java.awt.Button; //導入方法依賴的package包/類
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.");
}
}
示例3: ActionEventTest
import java.awt.Button; //導入方法依賴的package包/類
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.");
}
}
});
}