From 3dd0bd8c84910a297c286fb9cbc0320d75c1d219 Mon Sep 17 00:00:00 2001 From: "tejesh.r@oracle.com" Date: Tue, 15 Apr 2025 11:27:19 +0530 Subject: [PATCH 1/9] Open source --- test/jdk/ProblemList.txt | 1 + .../java/awt/Menu/MenuActionEventTest.java | 95 +++++++++++ .../jdk/java/awt/Menu/MenuVisibilityTest.java | 71 +++++++++ test/jdk/java/awt/Menu/RmInHideTest.java | 149 ++++++++++++++++++ test/jdk/java/awt/Menu/SetShortCutTest.java | 133 ++++++++++++++++ 5 files changed, 449 insertions(+) create mode 100644 test/jdk/java/awt/Menu/MenuActionEventTest.java create mode 100644 test/jdk/java/awt/Menu/MenuVisibilityTest.java create mode 100644 test/jdk/java/awt/Menu/RmInHideTest.java create mode 100644 test/jdk/java/awt/Menu/SetShortCutTest.java diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index b7f1d68a45186..c327b270cc847 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -258,6 +258,7 @@ java/awt/Component/GetScreenLocTest/GetScreenLocTest.java 4753654 generic-all java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java 8165863 macosx-all java/awt/Clipboard/HTMLTransferTest/HTMLTransferTest.java 8017454 macosx-all java/awt/Frame/MiscUndecorated/RepaintTest.java 8266244 macosx-aarch64 +java/awt/Menu/MenuVisibilityTest/MenuVisibilityTest.html 8161110 macosx-all java/awt/Modal/FileDialog/FileDialogAppModal1Test.java 7186009 macosx-all java/awt/Modal/FileDialog/FileDialogAppModal2Test.java 7186009 macosx-all java/awt/Modal/FileDialog/FileDialogAppModal3Test.java 7186009 macosx-all diff --git a/test/jdk/java/awt/Menu/MenuActionEventTest.java b/test/jdk/java/awt/Menu/MenuActionEventTest.java new file mode 100644 index 0000000000000..32e40a9044792 --- /dev/null +++ b/test/jdk/java/awt/Menu/MenuActionEventTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4094620 + * @summary MenuItem.enableEvents does not work + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuActionEventTest + */ + +import java.awt.AWTEvent; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.event.ActionEvent; + +public class MenuActionEventTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Click on the Menu and then on Menuitem on the frame. + 2. If you find the following message being printed:, + _MenuItem: action event", + click PASS, else click FAIL" + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(MenuActionEventTest::initialize) + .logArea() + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame f = new Frame("Menu Action Event Test"); + f.setLayout(new BorderLayout()); + f.setMenuBar(new MenuBar()); + Menu m = new _Menu("Menu"); + MenuBar mb = f.getMenuBar(); + mb.add(m); + MenuItem mi = new _MenuItem("Menuitem"); + m.add(mi); + f.setBounds(204, 152, 396, 300); + return f; + } +} + +class _Menu extends Menu { + public _Menu(String text) { + super(text); + enableEvents(AWTEvent.ACTION_EVENT_MASK); + } + + protected void processActionEvent(ActionEvent e) { + PassFailJFrame.log("_Menu: action event"); + super.processActionEvent(e); + } +} + +class _MenuItem extends MenuItem { + public _MenuItem(String text) { + super(text); + enableEvents(AWTEvent.ACTION_EVENT_MASK); + } + + protected void processActionEvent(ActionEvent e) { + PassFailJFrame.log("_MenuItem: action event"); + super.processActionEvent(e); + } +} diff --git a/test/jdk/java/awt/Menu/MenuVisibilityTest.java b/test/jdk/java/awt/Menu/MenuVisibilityTest.java new file mode 100644 index 0000000000000..fff7b7720ab0c --- /dev/null +++ b/test/jdk/java/awt/Menu/MenuVisibilityTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 5046491 6423258 + * @summary CheckboxMenuItem: menu text is missing from test frame + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuVisibilityTest +*/ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; + +public class MenuVisibilityTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Press on a MenuBar with a long name. + 2. Select "First item" in an opened menu. + If you see that "First menu item was pressed" press PASS + Otherwise press FAIL" + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(MenuVisibilityTest::initialize) + .logArea() + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Menu visibility test"); + String menuTitle = "I_have_never_seen_so_long_Menu_Title_" + + "!_ehe-eha-ehu-ehi_ugu-gu!!!_;)_BANG_BANG..."; + MenuBar menubar = new MenuBar(); + Menu menu = new Menu(menuTitle); + MenuItem menuItem = new MenuItem("First item"); + menuItem.addActionListener(e -> + PassFailJFrame.log("First menu item was pressed.")); + menu.add(menuItem); + menubar.add(menu); + frame.setMenuBar(menubar); + frame.setSize(100, 200); + return frame; + } +} diff --git a/test/jdk/java/awt/Menu/RmInHideTest.java b/test/jdk/java/awt/Menu/RmInHideTest.java new file mode 100644 index 0000000000000..8233b0bd461c3 --- /dev/null +++ b/test/jdk/java/awt/Menu/RmInHideTest.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4039387 + * @summary Checks that calling Frame.remove() within hide() doesn't + * cause SEGV + * @key headful + * @run main RmInHideTest + */ + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; + +public class RmInHideTest { + static volatile Point point; + static RmInHideTestFrame frame; + static volatile Dimension dimension; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + EventQueue.invokeAndWait(() -> { + frame = new RmInHideTestFrame(); + frame.setSize(200, 200); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + EventQueue.invokeAndWait(() -> { + point = frame.getButtonLocation(); + dimension = frame.getButtonDimension(); + }); + robot.mouseMove(point.x + dimension.width / 2, point.y + dimension.height / 2); + robot.mousePress(MouseEvent.BUTTON2_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON2_DOWN_MASK); + robot.waitForIdle(); + robot.delay(100); + System.out.println("Test pass"); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} + +class RmInHideTestFrame extends Frame implements ActionListener { + MenuBar menubar = null; + Button b; + + public RmInHideTestFrame() { + super("RmInHideTest"); + b = new Button("Hide"); + b.setActionCommand("hide"); + b.addActionListener(this); + add("Center", b); + + MenuBar bar = new MenuBar(); + + Menu menu = new Menu("Test1", true); + menu.add(new MenuItem("Test1A")); + menu.add(new MenuItem("Test1B")); + menu.add(new MenuItem("Test1C")); + bar.add(menu); + + menu = new Menu("Test2", true); + menu.add(new MenuItem("Test2A")); + menu.add(new MenuItem("Test2B")); + menu.add(new MenuItem("Test2C")); + bar.add(menu); + setMenuBar(bar); + } + + + public Dimension minimumSize() { + return new Dimension(200, 200); + } + + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + if (cmd.equals("hide")) { + hide(); + try { + Thread.currentThread().sleep(2000); + } catch (InterruptedException ex) { + // do nothing + } + show(); + } + } + + public void hide() { + menubar = getMenuBar(); + if (menubar != null) { + remove(menubar); + } + super.hide(); + } + + + public void show() { + if (menubar != null) { + setMenuBar(menubar); + } + super.show(); + } + + public Point getButtonLocation() { + return b.getLocationOnScreen(); + } + + public Dimension getButtonDimension() { + return b.getSize(); + } +} diff --git a/test/jdk/java/awt/Menu/SetShortCutTest.java b/test/jdk/java/awt/Menu/SetShortCutTest.java new file mode 100644 index 0000000000000..8ad9a6f2d017d --- /dev/null +++ b/test/jdk/java/awt/Menu/SetShortCutTest.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4203208 + * @summary setShortcut method does not display proper text on Menu component + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetShortCutTest + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; + +import static java.awt.event.KeyEvent.VK_META; +import static java.awt.event.KeyEvent.VK_SHIFT; + +public class SetShortCutTest { + public static void main(String[] args) throws Exception { + boolean isMac = System.getProperty("os.name").startsWith("Mac"); + String shortcut = "Ctrl+Shift+"; + if (isMac) { + shortcut = KeyEvent.getKeyText(VK_SHIFT) + "+" + KeyEvent.getKeyText(VK_META); + } + + String INSTRUCTIONS = """ + 1. Select menuitem 'Stuff -> Second' once to remove 'File -> First'. + 2. Select menuitem 'Stuff -> Second' again to add 'File -> First'. + 3. If menuitem 'File -> First' reads First """ + shortcut + """ + 'C', press PASS. Otherwise press FAIL. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(SetShortCutTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + return new TestMenuShortCut(); + } +} + +class TestMenuShortCut extends Frame implements ActionListener { + Menu menu1; + MenuItem item1; + MenuItem item2; + boolean beenHere; + + public TestMenuShortCut() { + setTitle("Set ShortCut test"); + beenHere = false; + MenuBar mTopMenu = buildMenu(); + setSize(300, 300); + this.setMenuBar(mTopMenu); + } + + + public MenuBar buildMenu() { + MenuBar bar; + bar = new MenuBar(); + menu1 = new Menu("File"); + item1 = new MenuItem("First"); + menu1.add(item1); + item1.setShortcut(new MenuShortcut(KeyEvent.VK_C, true)); + bar.add(menu1); + + //Stuff menu + item2 = new MenuItem("Second"); + Menu menu2 = new Menu("Stuff"); + menu2.add(item2); + item2.setShortcut(new MenuShortcut(KeyEvent.VK_C, false)); + bar.add(menu2); + + item1.addActionListener(this); + item2.addActionListener(this); + return bar; + } + + + public void actionPerformed(ActionEvent event) { + if (event.getSource() == item1) { + Frame temp = new Frame("Accelerator key is working for 'First'"); + temp.setSize(300, 50); + temp.setVisible(true); + } + + //Click on the "Stuff" menu to remove the "first" menu item + else if (event.getSource() == item2) { + //If the item has not been removed from the menu,then remove "First" from the "File" menu + if (beenHere == false) { + item1.removeActionListener(this); + menu1.remove(item1); + beenHere = true; + } else { + item1 = new MenuItem("First"); + menu1.add(item1); + item1.addActionListener(this); + item1.setShortcut(new MenuShortcut(KeyEvent.VK_C, true)); + beenHere = false; + } + } + } +} From 6702f514732be747de13502d87957c592fa91879 Mon Sep 17 00:00:00 2001 From: "tejesh.r@oracle.com" Date: Thu, 17 Apr 2025 16:02:36 +0530 Subject: [PATCH 2/9] Updated review comments --- .../java/awt/Menu/MenuActionEventTest.java | 41 +++---- .../jdk/java/awt/Menu/MenuVisibilityTest.java | 4 +- test/jdk/java/awt/Menu/RmInHideTest.java | 112 +++++++++--------- test/jdk/java/awt/Menu/SetShortCutTest.java | 103 ++++++++-------- 4 files changed, 129 insertions(+), 131 deletions(-) diff --git a/test/jdk/java/awt/Menu/MenuActionEventTest.java b/test/jdk/java/awt/Menu/MenuActionEventTest.java index 32e40a9044792..7460ba6b38ad1 100644 --- a/test/jdk/java/awt/Menu/MenuActionEventTest.java +++ b/test/jdk/java/awt/Menu/MenuActionEventTest.java @@ -42,12 +42,12 @@ public class MenuActionEventTest { public static void main(String[] args) throws Exception { String INSTRUCTIONS = """ 1. Click on the Menu and then on Menuitem on the frame. - 2. If you find the following message being printed:, + 2. If you find the following message being printed in + the test log area:, _MenuItem: action event", click PASS, else click FAIL" """; PassFailJFrame.builder() - .title("Test Instructions") .instructions(INSTRUCTIONS) .columns(35) .testUI(MenuActionEventTest::initialize) @@ -68,28 +68,29 @@ static Frame initialize() { f.setBounds(204, 152, 396, 300); return f; } -} -class _Menu extends Menu { - public _Menu(String text) { - super(text); - enableEvents(AWTEvent.ACTION_EVENT_MASK); - } + static class _Menu extends Menu { + public _Menu(String text) { + super(text); + enableEvents(AWTEvent.ACTION_EVENT_MASK); + } - protected void processActionEvent(ActionEvent e) { - PassFailJFrame.log("_Menu: action event"); - super.processActionEvent(e); + protected void processActionEvent(ActionEvent e) { + PassFailJFrame.log("_Menu: action event"); + super.processActionEvent(e); + } } -} -class _MenuItem extends MenuItem { - public _MenuItem(String text) { - super(text); - enableEvents(AWTEvent.ACTION_EVENT_MASK); - } + static class _MenuItem extends MenuItem { + public _MenuItem(String text) { + super(text); + enableEvents(AWTEvent.ACTION_EVENT_MASK); + } - protected void processActionEvent(ActionEvent e) { - PassFailJFrame.log("_MenuItem: action event"); - super.processActionEvent(e); + protected void processActionEvent(ActionEvent e) { + PassFailJFrame.log("_MenuItem: action event"); + super.processActionEvent(e); + } } + } diff --git a/test/jdk/java/awt/Menu/MenuVisibilityTest.java b/test/jdk/java/awt/Menu/MenuVisibilityTest.java index fff7b7720ab0c..cb74cd56e1a1f 100644 --- a/test/jdk/java/awt/Menu/MenuVisibilityTest.java +++ b/test/jdk/java/awt/Menu/MenuVisibilityTest.java @@ -40,11 +40,11 @@ public static void main(String[] args) throws Exception { String INSTRUCTIONS = """ 1. Press on a MenuBar with a long name. 2. Select "First item" in an opened menu. - If you see that "First menu item was pressed" press PASS + If you see that "First menu item was pressed" in + the test log area, press PASS Otherwise press FAIL" """; PassFailJFrame.builder() - .title("Test Instructions") .instructions(INSTRUCTIONS) .columns(35) .testUI(MenuVisibilityTest::initialize) diff --git a/test/jdk/java/awt/Menu/RmInHideTest.java b/test/jdk/java/awt/Menu/RmInHideTest.java index 8233b0bd461c3..0568519e8dbd9 100644 --- a/test/jdk/java/awt/Menu/RmInHideTest.java +++ b/test/jdk/java/awt/Menu/RmInHideTest.java @@ -76,74 +76,74 @@ public static void main(String[] args) throws Exception { }); } } -} -class RmInHideTestFrame extends Frame implements ActionListener { - MenuBar menubar = null; - Button b; - - public RmInHideTestFrame() { - super("RmInHideTest"); - b = new Button("Hide"); - b.setActionCommand("hide"); - b.addActionListener(this); - add("Center", b); - - MenuBar bar = new MenuBar(); - - Menu menu = new Menu("Test1", true); - menu.add(new MenuItem("Test1A")); - menu.add(new MenuItem("Test1B")); - menu.add(new MenuItem("Test1C")); - bar.add(menu); - - menu = new Menu("Test2", true); - menu.add(new MenuItem("Test2A")); - menu.add(new MenuItem("Test2B")); - menu.add(new MenuItem("Test2C")); - bar.add(menu); - setMenuBar(bar); - } + static class RmInHideTestFrame extends Frame implements ActionListener { + MenuBar menubar = null; + Button b; + + public RmInHideTestFrame() { + super("RmInHideTest"); + b = new Button("Hide"); + b.setActionCommand("hide"); + b.addActionListener(this); + add("Center", b); + + MenuBar bar = new MenuBar(); + + Menu menu = new Menu("Test1", true); + menu.add(new MenuItem("Test1A")); + menu.add(new MenuItem("Test1B")); + menu.add(new MenuItem("Test1C")); + bar.add(menu); + + menu = new Menu("Test2", true); + menu.add(new MenuItem("Test2A")); + menu.add(new MenuItem("Test2B")); + menu.add(new MenuItem("Test2C")); + bar.add(menu); + setMenuBar(bar); + } - public Dimension minimumSize() { - return new Dimension(200, 200); - } + public Dimension minimumSize() { + return new Dimension(200, 200); + } - public void actionPerformed(ActionEvent e) { - String cmd = e.getActionCommand(); - if (cmd.equals("hide")) { - hide(); - try { - Thread.currentThread().sleep(2000); - } catch (InterruptedException ex) { - // do nothing + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + if (cmd.equals("hide")) { + hide(); + try { + Thread.currentThread().sleep(2000); + } catch (InterruptedException ex) { + // do nothing + } + show(); } - show(); } - } - public void hide() { - menubar = getMenuBar(); - if (menubar != null) { - remove(menubar); + public void hide() { + menubar = getMenuBar(); + if (menubar != null) { + remove(menubar); + } + super.hide(); } - super.hide(); - } - public void show() { - if (menubar != null) { - setMenuBar(menubar); + public void show() { + if (menubar != null) { + setMenuBar(menubar); + } + super.show(); } - super.show(); - } - public Point getButtonLocation() { - return b.getLocationOnScreen(); - } + public Point getButtonLocation() { + return b.getLocationOnScreen(); + } - public Dimension getButtonDimension() { - return b.getSize(); + public Dimension getButtonDimension() { + return b.getSize(); + } } } diff --git a/test/jdk/java/awt/Menu/SetShortCutTest.java b/test/jdk/java/awt/Menu/SetShortCutTest.java index 8ad9a6f2d017d..f384ac86156f4 100644 --- a/test/jdk/java/awt/Menu/SetShortCutTest.java +++ b/test/jdk/java/awt/Menu/SetShortCutTest.java @@ -57,7 +57,6 @@ public static void main(String[] args) throws Exception { 'C', press PASS. Otherwise press FAIL. """; PassFailJFrame.builder() - .title("Test Instructions") .instructions(INSTRUCTIONS) .columns(35) .testUI(SetShortCutTest::initialize) @@ -68,65 +67,63 @@ public static void main(String[] args) throws Exception { static Frame initialize() { return new TestMenuShortCut(); } -} - -class TestMenuShortCut extends Frame implements ActionListener { - Menu menu1; - MenuItem item1; - MenuItem item2; - boolean beenHere; - - public TestMenuShortCut() { - setTitle("Set ShortCut test"); - beenHere = false; - MenuBar mTopMenu = buildMenu(); - setSize(300, 300); - this.setMenuBar(mTopMenu); - } - - public MenuBar buildMenu() { - MenuBar bar; - bar = new MenuBar(); - menu1 = new Menu("File"); - item1 = new MenuItem("First"); - menu1.add(item1); - item1.setShortcut(new MenuShortcut(KeyEvent.VK_C, true)); - bar.add(menu1); + static class TestMenuShortCut extends Frame implements ActionListener { + Menu menu1; + MenuItem item1; + MenuItem item2; + boolean beenHere; - //Stuff menu - item2 = new MenuItem("Second"); - Menu menu2 = new Menu("Stuff"); - menu2.add(item2); - item2.setShortcut(new MenuShortcut(KeyEvent.VK_C, false)); - bar.add(menu2); + public TestMenuShortCut() { + setTitle("Set ShortCut test"); + beenHere = false; + MenuBar mTopMenu = buildMenu(); + setSize(300, 300); + this.setMenuBar(mTopMenu); + } - item1.addActionListener(this); - item2.addActionListener(this); - return bar; - } + public MenuBar buildMenu() { + MenuBar bar; + bar = new MenuBar(); + menu1 = new Menu("File"); + item1 = new MenuItem("First"); + menu1.add(item1); + item1.setShortcut(new MenuShortcut(KeyEvent.VK_C, true)); + bar.add(menu1); + //Stuff menu + item2 = new MenuItem("Second"); + Menu menu2 = new Menu("Stuff"); + menu2.add(item2); + item2.setShortcut(new MenuShortcut(KeyEvent.VK_C, false)); + bar.add(menu2); - public void actionPerformed(ActionEvent event) { - if (event.getSource() == item1) { - Frame temp = new Frame("Accelerator key is working for 'First'"); - temp.setSize(300, 50); - temp.setVisible(true); + item1.addActionListener(this); + item2.addActionListener(this); + return bar; } - //Click on the "Stuff" menu to remove the "first" menu item - else if (event.getSource() == item2) { - //If the item has not been removed from the menu,then remove "First" from the "File" menu - if (beenHere == false) { - item1.removeActionListener(this); - menu1.remove(item1); - beenHere = true; - } else { - item1 = new MenuItem("First"); - menu1.add(item1); - item1.addActionListener(this); - item1.setShortcut(new MenuShortcut(KeyEvent.VK_C, true)); - beenHere = false; + public void actionPerformed(ActionEvent event) { + if (event.getSource() == item1) { + Frame temp = new Frame("Accelerator key is working for 'First'"); + temp.setSize(300, 50); + temp.setVisible(true); + } + + //Click on the "Stuff" menu to remove the "first" menu item + else if (event.getSource() == item2) { + //If the item has not been removed from the menu,then remove "First" from the "File" menu + if (beenHere == false) { + item1.removeActionListener(this); + menu1.remove(item1); + beenHere = true; + } else { + item1 = new MenuItem("First"); + menu1.add(item1); + item1.addActionListener(this); + item1.setShortcut(new MenuShortcut(KeyEvent.VK_C, true)); + beenHere = false; + } } } } From 92b224aca6d2a69ccfc1b3f1be3c6074b738b6e4 Mon Sep 17 00:00:00 2001 From: "tejesh.r@oracle.com" Date: Fri, 18 Apr 2025 17:03:56 +0530 Subject: [PATCH 3/9] Update PL --- test/jdk/ProblemList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index c327b270cc847..9c26bae6fea0b 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -258,7 +258,7 @@ java/awt/Component/GetScreenLocTest/GetScreenLocTest.java 4753654 generic-all java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java 8165863 macosx-all java/awt/Clipboard/HTMLTransferTest/HTMLTransferTest.java 8017454 macosx-all java/awt/Frame/MiscUndecorated/RepaintTest.java 8266244 macosx-aarch64 -java/awt/Menu/MenuVisibilityTest/MenuVisibilityTest.html 8161110 macosx-all +java/awt/Menu/MenuVisibilityTest.java 8161110 macosx-all java/awt/Modal/FileDialog/FileDialogAppModal1Test.java 7186009 macosx-all java/awt/Modal/FileDialog/FileDialogAppModal2Test.java 7186009 macosx-all java/awt/Modal/FileDialog/FileDialogAppModal3Test.java 7186009 macosx-all From 7a22269d0addb47768f5ad7cc6e65558e3550327 Mon Sep 17 00:00:00 2001 From: "tejesh.r@oracle.com" Date: Mon, 21 Apr 2025 20:14:27 +0530 Subject: [PATCH 4/9] Update PL --- test/jdk/ProblemList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 9c26bae6fea0b..509987d1c2994 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -258,7 +258,6 @@ java/awt/Component/GetScreenLocTest/GetScreenLocTest.java 4753654 generic-all java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java 8165863 macosx-all java/awt/Clipboard/HTMLTransferTest/HTMLTransferTest.java 8017454 macosx-all java/awt/Frame/MiscUndecorated/RepaintTest.java 8266244 macosx-aarch64 -java/awt/Menu/MenuVisibilityTest.java 8161110 macosx-all java/awt/Modal/FileDialog/FileDialogAppModal1Test.java 7186009 macosx-all java/awt/Modal/FileDialog/FileDialogAppModal2Test.java 7186009 macosx-all java/awt/Modal/FileDialog/FileDialogAppModal3Test.java 7186009 macosx-all @@ -809,3 +808,4 @@ java/awt/Checkbox/CheckboxBoxSizeTest.java 8340870 windows-all java/awt/Checkbox/CheckboxIndicatorSizeTest.java 8340870 windows-all java/awt/Checkbox/CheckboxNullLabelTest.java 8340870 windows-all java/awt/dnd/WinMoveFileToShellTest.java 8341665 windows-all +java/awt/Menu/MenuVisibilityTest.java 8161110 macosx-all From a83a393679bb67310c368c035e139d0e825d8556 Mon Sep 17 00:00:00 2001 From: "tejesh.r@oracle.com" Date: Tue, 22 Apr 2025 08:43:55 +0530 Subject: [PATCH 5/9] Update review comments --- test/jdk/java/awt/Menu/SetShortCutTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jdk/java/awt/Menu/SetShortCutTest.java b/test/jdk/java/awt/Menu/SetShortCutTest.java index f384ac86156f4..52fa9c2c22bff 100644 --- a/test/jdk/java/awt/Menu/SetShortCutTest.java +++ b/test/jdk/java/awt/Menu/SetShortCutTest.java @@ -112,7 +112,8 @@ public void actionPerformed(ActionEvent event) { //Click on the "Stuff" menu to remove the "first" menu item else if (event.getSource() == item2) { - //If the item has not been removed from the menu,then remove "First" from the "File" menu + //If the item has not been removed from the menu, + //then remove "First" from the "File" menu if (beenHere == false) { item1.removeActionListener(this); menu1.remove(item1); From 584f58b30a031db7d3e7f1c66e45ce39aca2da26 Mon Sep 17 00:00:00 2001 From: "tejesh.r@oracle.com" Date: Tue, 22 Apr 2025 10:02:29 +0530 Subject: [PATCH 6/9] Updated review comments --- test/jdk/java/awt/Menu/MenuActionEventTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/jdk/java/awt/Menu/MenuActionEventTest.java b/test/jdk/java/awt/Menu/MenuActionEventTest.java index 7460ba6b38ad1..70fcc81ac864c 100644 --- a/test/jdk/java/awt/Menu/MenuActionEventTest.java +++ b/test/jdk/java/awt/Menu/MenuActionEventTest.java @@ -75,6 +75,7 @@ public _Menu(String text) { enableEvents(AWTEvent.ACTION_EVENT_MASK); } + @Override protected void processActionEvent(ActionEvent e) { PassFailJFrame.log("_Menu: action event"); super.processActionEvent(e); @@ -87,6 +88,7 @@ public _MenuItem(String text) { enableEvents(AWTEvent.ACTION_EVENT_MASK); } + @Override protected void processActionEvent(ActionEvent e) { PassFailJFrame.log("_MenuItem: action event"); super.processActionEvent(e); From b1c137a7428db9d6648d1dc9f6dd43b8b42538c9 Mon Sep 17 00:00:00 2001 From: "tejesh.r@oracle.com" Date: Tue, 22 Apr 2025 10:45:46 +0530 Subject: [PATCH 7/9] Updated review comments --- test/jdk/java/awt/Menu/RmInHideTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/jdk/java/awt/Menu/RmInHideTest.java b/test/jdk/java/awt/Menu/RmInHideTest.java index 0568519e8dbd9..b2d6840064749 100644 --- a/test/jdk/java/awt/Menu/RmInHideTest.java +++ b/test/jdk/java/awt/Menu/RmInHideTest.java @@ -104,11 +104,12 @@ public RmInHideTestFrame() { setMenuBar(bar); } - + @Override public Dimension minimumSize() { return new Dimension(200, 200); } + @Override public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("hide")) { @@ -122,6 +123,7 @@ public void actionPerformed(ActionEvent e) { } } + @Override public void hide() { menubar = getMenuBar(); if (menubar != null) { @@ -131,6 +133,7 @@ public void hide() { } + @Override public void show() { if (menubar != null) { setMenuBar(menubar); From b858947253b037475d5a3d1638021fb7d6b5ff79 Mon Sep 17 00:00:00 2001 From: "tejesh.r@oracle.com" Date: Tue, 22 Apr 2025 11:10:35 +0530 Subject: [PATCH 8/9] Updated review comments --- test/jdk/java/awt/Menu/SetShortCutTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/jdk/java/awt/Menu/SetShortCutTest.java b/test/jdk/java/awt/Menu/SetShortCutTest.java index 52fa9c2c22bff..b60b83dff9a9f 100644 --- a/test/jdk/java/awt/Menu/SetShortCutTest.java +++ b/test/jdk/java/awt/Menu/SetShortCutTest.java @@ -91,7 +91,7 @@ public MenuBar buildMenu() { item1.setShortcut(new MenuShortcut(KeyEvent.VK_C, true)); bar.add(menu1); - //Stuff menu + // Stuff menu item2 = new MenuItem("Second"); Menu menu2 = new Menu("Stuff"); menu2.add(item2); @@ -103,6 +103,7 @@ public MenuBar buildMenu() { return bar; } + @Override public void actionPerformed(ActionEvent event) { if (event.getSource() == item1) { Frame temp = new Frame("Accelerator key is working for 'First'"); @@ -110,10 +111,10 @@ public void actionPerformed(ActionEvent event) { temp.setVisible(true); } - //Click on the "Stuff" menu to remove the "first" menu item + // Click on the "Stuff" menu to remove the "first" menu item else if (event.getSource() == item2) { - //If the item has not been removed from the menu, - //then remove "First" from the "File" menu + // If the item has not been removed from the menu, + // then remove "First" from the "File" menu if (beenHere == false) { item1.removeActionListener(this); menu1.remove(item1); From 4c8fe2cc7902a9d72f6bc887f9e9e8bb34f7285a Mon Sep 17 00:00:00 2001 From: "tejesh.r@oracle.com" Date: Tue, 22 Apr 2025 12:19:56 +0530 Subject: [PATCH 9/9] Empty commit