-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
I am running 1.6 FCS, but combobox in BugParade didn't let me select it
A DESCRIPTION OF THE PROBLEM :
Calling JMenuItem.setHorizontalAlignment() makes text of item invisible when it's shown in a JPopupMenu.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run supplied source code.
Minimize the JInternalFrame, then right click on it.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JMenuItem on JPopupMenu displays its Label
ACTUAL -
Label not visible if setHorizontalAlignment() was called
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.adp.e.client.desktop;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.SwingConstants;
public class PopupBug
{
private static class FrameListener extends MouseAdapter
{
private Component m_comp;
public FrameListener(Component comp)
{
m_comp = comp;
}
public void mouseReleased(MouseEvent e)
{
if (e.isPopupTrigger())
{
JPopupMenu pm = new JPopupMenu();
JMenuItem mi = new JMenuItem("First Item");
// Comment out this line and MenuItem text is visible
mi.setHorizontalAlignment(SwingConstants.CENTER);
pm.add(mi);
pm.show(m_comp, e.getX(), e.getY());
}
}
}
public static void main(String[] args)
{
JFrame frame = new JFrame("Popup bug under 1.6");
JDesktopPane dp = new JDesktopPane();
frame.setContentPane(dp);
JInternalFrame iFrame = new JInternalFrame("Right click when minimized", true, true, true, true);
iFrame.setSize(new Dimension(100, 100));
iFrame.setVisible(true);
dp.add(iFrame);
JComponent di = iFrame.getDesktopIcon();
for(int i = 0; i < di.getComponentCount(); i++)
{
Component curChild = di.getComponent(i);
if (curChild instanceof JButton)
{
curChild.addMouseListener(new FrameListener(curChild));
}
}
frame.setSize(new Dimension(400,200));
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I can get by not calling setHorizontalAlignment(), but thought Sun would want to know about this.
Release Regression From : 5.0u7
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
I am running 1.6 FCS, but combobox in BugParade didn't let me select it
A DESCRIPTION OF THE PROBLEM :
Calling JMenuItem.setHorizontalAlignment() makes text of item invisible when it's shown in a JPopupMenu.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run supplied source code.
Minimize the JInternalFrame, then right click on it.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JMenuItem on JPopupMenu displays its Label
ACTUAL -
Label not visible if setHorizontalAlignment() was called
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.adp.e.client.desktop;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.SwingConstants;
public class PopupBug
{
private static class FrameListener extends MouseAdapter
{
private Component m_comp;
public FrameListener(Component comp)
{
m_comp = comp;
}
public void mouseReleased(MouseEvent e)
{
if (e.isPopupTrigger())
{
JPopupMenu pm = new JPopupMenu();
JMenuItem mi = new JMenuItem("First Item");
// Comment out this line and MenuItem text is visible
mi.setHorizontalAlignment(SwingConstants.CENTER);
pm.add(mi);
pm.show(m_comp, e.getX(), e.getY());
}
}
}
public static void main(String[] args)
{
JFrame frame = new JFrame("Popup bug under 1.6");
JDesktopPane dp = new JDesktopPane();
frame.setContentPane(dp);
JInternalFrame iFrame = new JInternalFrame("Right click when minimized", true, true, true, true);
iFrame.setSize(new Dimension(100, 100));
iFrame.setVisible(true);
dp.add(iFrame);
JComponent di = iFrame.getDesktopIcon();
for(int i = 0; i < di.getComponentCount(); i++)
{
Component curChild = di.getComponent(i);
if (curChild instanceof JButton)
{
curChild.addMouseListener(new FrameListener(curChild));
}
}
frame.setSize(new Dimension(400,200));
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I can get by not calling setHorizontalAlignment(), but thought Sun would want to know about this.
Release Regression From : 5.0u7
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
- duplicates
-
JDK-6458123 Bugs in menu item layout
- Closed