-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P4
-
Affects Version/s: 7, 8
-
Component/s: client-libs
-
master
-
x86_64
-
linux
FULL PRODUCT VERSION :
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java Hotspot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux 3.10.0-123.el7.x86_64
SunOS 5.10 Generic_150400-20
A DESCRIPTION OF THE PROBLEM :
This applies to a JFrame with the Window decorations provided by the Metal LookAndFeel. The system menu icon (e.g., which shows Restore, Minimize, Maximize, and Close menu options when clicked) does not activate when clicked on the right half of the icon. This icon is 16 pixels wide; only the leftmost 9 pixels of the icon will open the popup menu when clicked.
This problem goes back at least to Java 1.6.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run any program with the Metal LookAndFeel and JFrame.setDefaultLookAndFeelDecorated(true). The system menu icon is on the left side of the title bar. Click anywhere on the right half of that icon and the system menu is not displayed.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The right half of the system menu icon should display the popup menu (e.g., which shows Restore, Minimize, Maximize, and Close menu options), same as when the left half is clicked.
ACTUAL -
Clicking on the right half of the system menu icon does nothing.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class MetalBug {
public static void main(String[] argv) {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 100);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
In MetalTitlePane.java, the createMenu method creates a JMenu with an empty string. Changing the text of this component to a single space character properly sizes the menu button underlying the system menu icon. To workaround from the application level:
for (JComponent component : SwingUtils.getDescendantsOfType(JComponent.class, window, true)) {
if (component.getClass().getName().contains("MetalTitlePane$SystemMenuBar")) {
((JMenuBar)component.getMenu(0).setText(" ");
break;
}
}
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java Hotspot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux 3.10.0-123.el7.x86_64
SunOS 5.10 Generic_150400-20
A DESCRIPTION OF THE PROBLEM :
This applies to a JFrame with the Window decorations provided by the Metal LookAndFeel. The system menu icon (e.g., which shows Restore, Minimize, Maximize, and Close menu options when clicked) does not activate when clicked on the right half of the icon. This icon is 16 pixels wide; only the leftmost 9 pixels of the icon will open the popup menu when clicked.
This problem goes back at least to Java 1.6.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run any program with the Metal LookAndFeel and JFrame.setDefaultLookAndFeelDecorated(true). The system menu icon is on the left side of the title bar. Click anywhere on the right half of that icon and the system menu is not displayed.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The right half of the system menu icon should display the popup menu (e.g., which shows Restore, Minimize, Maximize, and Close menu options), same as when the left half is clicked.
ACTUAL -
Clicking on the right half of the system menu icon does nothing.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class MetalBug {
public static void main(String[] argv) {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 100);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
In MetalTitlePane.java, the createMenu method creates a JMenu with an empty string. Changing the text of this component to a single space character properly sizes the menu button underlying the system menu icon. To workaround from the application level:
for (JComponent component : SwingUtils.getDescendantsOfType(JComponent.class, window, true)) {
if (component.getClass().getName().contains("MetalTitlePane$SystemMenuBar")) {
((JMenuBar)component.getMenu(0).setText(" ");
break;
}
}
- links to
-
Commit(master)
openjdk/jdk/463b9e00
-
Review(master)
openjdk/jdk/29808