16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.awt.Button;
25 import java.awt.CardLayout;
26 import java.awt.Font;
27 import java.awt.Frame;
28 import java.awt.Menu;
29 import java.awt.MenuBar;
30 import java.awt.Point;
31 import java.awt.Robot;
32 import java.awt.event.ActionEvent;
33 import java.awt.event.ActionListener;
34 import java.awt.event.InputEvent;
35
36 import jdk.testlibrary.OSInfo;
37
38 /**
39 * @test
40 * @key headful
41 * @bug 6263470
42 * @summary Tries to change font of MenuBar. Test passes if the font has changed
43 * fails otherwise.
44 * @library ../../../../lib/testlibrary
45 * @build jdk.testlibrary.OSInfo
46 * @author Vyacheslav.Baranov: area=menu
47 * @run main MenuBarSetFont
48 */
49 public final class MenuBarSetFont {
50
51 private static final Frame frame = new Frame();
52 private static final MenuBar mb = new MenuBar();
53 private static volatile boolean clicked;
54
55 private static final class Listener implements ActionListener {
56 @Override
57 public void actionPerformed(final ActionEvent e) {
58 //Click on this button is performed
59 //_only_ if font of MenuBar is not changed on time
60 MenuBarSetFont.clicked = true;
61 }
62 }
63
64 private static void addMenu() {
65 mb.add(new Menu("w"));
66 frame.validate();
67 }
68
69 public static void main(final String[] args) throws Exception {
70
71 if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
72 System.err.println("This test is not for OS X. Menu.setFont() is not supported on OS X.");
73 return;
74 }
75
76 //Components initialization.
77 frame.setMenuBar(mb);
78 mb.setFont(new Font("Helvetica", Font.ITALIC, 5));
79
80 final Robot r = new Robot();
81 r.setAutoDelay(200);
82
83 final Button button = new Button("Click Me");
84 button.addActionListener(new Listener());
85 frame.setLayout(new CardLayout());
86 frame.add(button, "First");
87 frame.setSize(400, 400);
88 frame.setVisible(true);
89 sleep(r);
90
91 final int fInsets = frame.getInsets().top; //Frame insets without menu.
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.awt.Button;
25 import java.awt.CardLayout;
26 import java.awt.Font;
27 import java.awt.Frame;
28 import java.awt.Menu;
29 import java.awt.MenuBar;
30 import java.awt.Point;
31 import java.awt.Robot;
32 import java.awt.event.ActionEvent;
33 import java.awt.event.ActionListener;
34 import java.awt.event.InputEvent;
35
36 import jdk.test.lib.Platform;
37
38 /**
39 * @test
40 * @key headful
41 * @bug 6263470
42 * @summary Tries to change font of MenuBar. Test passes if the font has changed
43 * fails otherwise.
44 * @library /test/lib
45 * @build jdk.test.lib.Platform
46 * @author Vyacheslav.Baranov: area=menu
47 * @run main MenuBarSetFont
48 */
49 public final class MenuBarSetFont {
50
51 private static final Frame frame = new Frame();
52 private static final MenuBar mb = new MenuBar();
53 private static volatile boolean clicked;
54
55 private static final class Listener implements ActionListener {
56 @Override
57 public void actionPerformed(final ActionEvent e) {
58 //Click on this button is performed
59 //_only_ if font of MenuBar is not changed on time
60 MenuBarSetFont.clicked = true;
61 }
62 }
63
64 private static void addMenu() {
65 mb.add(new Menu("w"));
66 frame.validate();
67 }
68
69 public static void main(final String[] args) throws Exception {
70
71 if (Platform.isOSX()) {
72 System.err.println("This test is not for OS X. Menu.setFont() is not supported on OS X.");
73 return;
74 }
75
76 //Components initialization.
77 frame.setMenuBar(mb);
78 mb.setFont(new Font("Helvetica", Font.ITALIC, 5));
79
80 final Robot r = new Robot();
81 r.setAutoDelay(200);
82
83 final Button button = new Button("Click Me");
84 button.addActionListener(new Listener());
85 frame.setLayout(new CardLayout());
86 frame.add(button, "First");
87 frame.setSize(400, 400);
88 frame.setVisible(true);
89 sleep(r);
90
91 final int fInsets = frame.getInsets().top; //Frame insets without menu.
|