I am getting a checkmark icon on my JMenuItem only after initializing a JideSplitPane (or I assume any other Jide component). The problem is only seen on the system look & feel for Vista. It may happen on XP too, haven't checked.
Note in the following code, a checkmark icon appears next to the "Test Menu Item." Commenting out the "new JideSplitPane()" call allows the JMenuItem to be created correctly (ie. no checkmark / no Jide components initialized).
Additionally, if the call to "new JideSplitPane()" is made before the JMenuItem, a different gradient icon is displayed and the menu coloration is wrong.
Thanks.
Adam
- Code: Select all
import java.awt.Dimension;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import com.jidesoft.swing.JideSplitPane;
public class JMenuItemTest implements Runnable {
@Override
public void run() {
JFrame frame = new JFrame("Just a Test");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(300, 200));
// call new JideSplitPane() here to see the other problem.
JMenuItem menuItem = new JMenuItem("Test Menu Item");
JMenu menu = new JMenu("Menu");
JMenuBar menuBar = new JMenuBar();
menu.add(menuItem);
menuBar.add(menu);
frame.setJMenuBar(menuBar);
// for whatever reason, calling a new JideSplitPane() causes a checkmark to appear
// on the JMenuItem. I am assuming initialization of any Jide component will do this.
// look at the checkmark icon on the JMenuItem 'Just a Test'
// comment out this line to see "normal" behavior
//
// Note that moving this call to above the JMenuItem construction creates a totally different
// icon related problem, some sort of gradient as the icon. If the JMenuItem is created,
// you get the checkmark. If it's not created yet, you get a blue-to-whiteish diagnol gradient.
// Additionally, the coloration of the menu item is not correct when calling the new JideSplitPane
// before the JMenuItem creation.
new JideSplitPane();
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
public static void main(String[] args) throws Exception {
// Note, this is seen on Vista
// Unsure about other platforms, like XP.
// Default look & feel doesn't have the problem (Metal, etc.)
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
EventQueue.invokeLater(new JMenuItemTest());
}
}