下面列出了java.awt.Button#hasFocus ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}