-
Bug
-
Resolution: Fixed
-
P4
-
8u66, 9
-
b124
-
x86_64
-
windows_7, windows_10
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8197306 | 8u192 | Unassigned | P4 | Resolved | Fixed | b01 |
JDK-8195491 | 8u172 | Unassigned | P4 | Resolved | Fixed | b03 |
JDK-8190098 | 8u162 | Unassigned | P4 | Resolved | Fixed | b04 |
JDK-8175157 | 8u161 | Mikhail Cherkasov | P4 | Resolved | Fixed | b01 |
JDK-8171223 | 8u152 | Mikhail Cherkasov | P4 | Resolved | Fixed | b01 |
JDK-8185211 | 8u144 | Unassigned | P4 | Resolved | Fixed | b31 |
JDK-8183068 | 8u141 | Unassigned | P4 | Resolved | Fixed | b31 |
JDK-8173351 | 8u121 | Mikhail Cherkasov | P4 | Resolved | Fixed | b32 |
JDK-8192354 | emb-8u161 | Unassigned | P4 | Resolved | Fixed | b01 |
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.10586]
A DESCRIPTION OF THE PROBLEM :
The icon appears twice, on the left AND the right when you change the default position in a JMenuItem using setHorizontalTextPosition() with Windows Look and Feel.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See self contained test below.
Or just create a JMenuItem with an icon and text, then change the default position of the icon using setHorizontalTextPosition(SwingConstants.LEFT)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Can change the icon position in a JMenuItem using setHorizontalTextPosition()
ACTUAL -
The icon appears twice, on the left and the right side of the JMenuItem
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
public class WinMenuItemIcon {
public static void main(String[] args) {
//NOTE: Bug happens with Windows L&F
String name = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel( name );
} catch (Exception e) {
e.printStackTrace();
}
JFrame frame = new JFrame();
frame.setTitle("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Menu");
ImageIcon icon = createIcon();
JMenuItem menuItem = new JMenuItem("Command", icon);
menuItem.setHorizontalTextPosition(SwingConstants.LEFT);
menu.add(menuItem);
menuBar.add(menu);
frame.setJMenuBar(menuBar);
frame.setPreferredSize(new Dimension(500, 500));
frame.pack();
frame.setVisible(true);
}
protected static ImageIcon createIcon() {
BufferedImage bi = new BufferedImage(25,25,BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.createGraphics();
g.setColor(Color.RED);
g.fillOval(0,0, 25, 25);
return new ImageIcon(bi);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't use Windows Look and Feel. Works fine with default Java look and feel.
- backported by
-
JDK-8171223 Double icons with JMenuItem setHorizontalTextPosition on Win 10
-
- Resolved
-
-
JDK-8173351 Double icons with JMenuItem setHorizontalTextPosition on Win 10
-
- Resolved
-
-
JDK-8175157 Double icons with JMenuItem setHorizontalTextPosition on Win 10
-
- Resolved
-
-
JDK-8183068 Double icons with JMenuItem setHorizontalTextPosition on Win 10
-
- Resolved
-
-
JDK-8185211 Double icons with JMenuItem setHorizontalTextPosition on Win 10
-
- Resolved
-
-
JDK-8190098 Double icons with JMenuItem setHorizontalTextPosition on Win 10
-
- Resolved
-
-
JDK-8192354 Double icons with JMenuItem setHorizontalTextPosition on Win 10
-
- Resolved
-
-
JDK-8195491 Double icons with JMenuItem setHorizontalTextPosition on Win 10
-
- Resolved
-
-
JDK-8197306 Double icons with JMenuItem setHorizontalTextPosition on Win 10
-
- Resolved
-
- relates to
-
JDK-8216329 Cannot resize CheckBoxItemMenu in Synth L&F with setHorizontalTextPosition
-
- Resolved
-