Skip to main content

Any Workarounds for Windows 7 menu item regressions?

9 replies [Last post]
osbald
Offline
Joined: 2003-06-13
Points: 0

Just noticed that under Windows 7 (Vista too?) if you use JCheckBoxMenuItem or JRadioButtonMenuItem and set an icon the checkbox component gets obscured completely. Anybody worked out a quick & dirty workaround for the issues?

What I'm expecting to see is a menuitem with text, its associated icon and a checkbox - all three. Much like I do if I leave the Metal/Ocean Java LAF active.

All seems to work in Windows XP, we're working with 1.5u21 and FYI I've also tried 1.6u18 and a recent 1.7snapshot without success.

- Richard

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kleopatra
Offline
Joined: 2003-06-11
Points: 0

forgot to answer earlier - but was reminded in a thread over at SwingX:

http://forums.java.net/jive/thread.jspa?messageID=393669&#393669

Executive summary: Vista don't seem to be have any

Cheers
Jeanette

kirillcool
Offline
Joined: 2004-11-17
Points: 0

A screenshot of a native Windows app under Win 7 / Windows Vista that shows how a native selected menu item looks like will help here.

osbald
Offline
Joined: 2003-06-13
Points: 0

Happen to know of any in the standard OS/ MS Office Kirill? I suspect they're supposed to look more like they do in WindowsPLAF on WindowsXP bar the Vista styling. Gonna lose this Windows 7 laptop soon as I'm moving on.

kirillcool
Offline
Joined: 2004-11-17
Points: 0

Calculator / Notepad / Eclipse might have a few selectable menu items.

alexfromsun
Offline
Joined: 2005-09-05
Points: 0

Hello Richard

Could you please post a simple test case for this problem?

I quickly tried to reproduce it on SwingSet2 - no luck

Thanks
alexp

osbald
Offline
Joined: 2003-06-13
Points: 0

The trick is to set icons on CheckBoxMenuItems (or RadioButtonMenuItems) and have the right (wrong) version of windows.
Uploaded some screenshots of how I expected these too work under Java Look & feel: as the Javadoc says you see the widget and both the label and the icon. Don't have access to XP from the office will post a shot later from home, but its look&feel is more like the CrossPlatform image (can see & use the menuitems widget state).

However on Windows 7 the icon appears to replace the MenuItems CheckBox/RadioBox entirely? This was a particular problem for me as the icon in our app in this case where much more important than their label (in many other tables, forms often the labels aren't used at all). Suspect Vista is likely to share same problem as Windows7? can anybody verify that?

Source:
[code]

import java.awt.BorderLayout;
import java.awt.Container;
import java.net.URL;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class CheckBoxMenuItemIssue {
private static Icon redFlagIcon, yellowFlagIcon;

public static void main(String[] args) throws Exception {
// Verified problems with Java 1.5 & 1.6 WindowsLookAndFeel under Windows 7 (most prob. Vista too)
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
redFlagIcon = new ImageIcon(new URL("http://wiki.famfamfam.googlecode.com/hg/images/flag_red.png"));
yellowFlagIcon = new ImageIcon(new URL("http://wiki.famfamfam.googlecode.com/hg/images/flag_yellow.png"));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new CheckBoxMenuItemIssue();
}
});
}

public CheckBoxMenuItemIssue() {
JFrame frame = new JFrame(this.getClass().getSimpleName());
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.getContentPane().add(createUI());
frame.setSize(300, 200);
frame.setVisible(true);
}

Container createUI() {
JPanel content = new JPanel(new BorderLayout());
content.add(new JLabel("Right-Click to show PopupMenu"));
JPopupMenu popupMenu = new JPopupMenu();
content.setComponentPopupMenu(popupMenu);

JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem("DeSelected CheckBoxMenuItem");
popupMenu.add(checkBoxMenuItem);
JCheckBoxMenuItem checkBoxMenuItem2 = new JCheckBoxMenuItem("Selected CheckBoxMenuItem");
checkBoxMenuItem2.setSelected(true);
popupMenu.add(checkBoxMenuItem2);
JCheckBoxMenuItem checkBoxMenuItem3 = new JCheckBoxMenuItem("DeSelected CheckBoxMenuItem with Icon", redFlagIcon);
popupMenu.add(checkBoxMenuItem3);
JCheckBoxMenuItem checkBoxMenuItem4 = new JCheckBoxMenuItem("Selected CheckBoxMenuItem with Icon", yellowFlagIcon);
checkBoxMenuItem4.setSelected(true);
popupMenu.add(checkBoxMenuItem4);
popupMenu.addSeparator();

JRadioButtonMenuItem radioButtonMenuItem = new JRadioButtonMenuItem("DeSelected RadioButtonMenuItem");
popupMenu.add(radioButtonMenuItem);
JRadioButtonMenuItem radioButtonMenuItem2 = new JRadioButtonMenuItem("Selected RadioButtonMenuItem");
radioButtonMenuItem2.setSelected(true);
popupMenu.add(radioButtonMenuItem2);
JRadioButtonMenuItem radioButtonMenuItem3 = new JRadioButtonMenuItem("DeSelected RadioButtonMenuItem with Icon", redFlagIcon);
popupMenu.add(radioButtonMenuItem3);
JRadioButtonMenuItem radioButtonMenuItem4 = new JRadioButtonMenuItem("Selected RadioButtonMenuItem with Icon", yellowFlagIcon);
radioButtonMenuItem4.setSelected(true);
popupMenu.add(radioButtonMenuItem4);

popupMenu.setLocation(10,40);
popupMenu.setVisible(true);

return content;
}
}
[/code]

kleopatra
Offline
Joined: 2003-06-11
Points: 0

> However on Windows 7 the icon appears to replace
> the MenuItems CheckBox/RadioBox entirely? This was a
> particular problem for me as the icon in our app in
> this case where much more important than their label
> (in many other tables, forms often the labels aren't
> used at all). Suspect Vista is likely to share same
> problem as Windows7? can anybody verify that?
>

yes, same in Vista ... doooohhh. Seems to be a regression: remember having seen similar bad behaviour with icons in menu items in "early" (like 1.3/4 or so, forgot the details) jdks. Should be a max priority issue to fix, IMO

CU
Jeanette

Message was edited by: kleopatra

hmm ... quotes running wild? There were html tags inside the quoted text, removing them did the trick, how annoying. Was that you, Richard, or the forum itself?

osbald
Offline
Joined: 2003-06-13
Points: 0

Seemed like a clear regression to me, infuriating as they run daily releases here (madness!) and I wasn't expecting to run slap into such an issue.. Swing keeps on surprising me. If anybodies really desperate for a workaround you could push the MetalLookAndFeelCheckBoxMenuItemUI into your CheckBoxMenuItem setUI().. don't expect you to condone that. Ticket got shelved anyway as it took more than a day to fix, so I'm in no rush as things stand.

Guessed at Vista as precious little appears to be happening for Windows7 desktop integration, esp. when we're talking Java 1.5 - which is still the company standard (UI was briefly java6 but quickly had to revert after customer complaints).

> hmm ... quotes running wild? There were html tags
> inside the quoted text, removing them did the trick,
> how annoying. Was that you, Richard, or the forum
> itself?

I added the html link myself, the href was a bit long and unappetizing and they've blocked tinyurl & similar via the proxies at work.. gah! Guess the quote button on the forum dosn't care for html.

- Richard

kleopatra
Offline
Joined: 2003-06-11
Points: 0

>
> > hmm ... quotes running wild? There were html tags
> > inside the quoted text, removing them did the
> trick,
> > how annoying. Was that you, Richard, or the forum
> > itself?
>
> I added the html link myself, the href was a bit long
> and unappetizing and they've blocked tinyurl &
> similar via the proxies at work.. gah! Guess the
> quote button on the forum dosn't care for html.
>

Karl knows a custom forum tag for references, with square brackets (forgot it immediately after he posted it ). Funny thing was that your text contained html paragraph tags - that's what the quote seemed to have stumbled across - no idea where they came from. Maybe auto-include if there is any "real" html tag posted. Forum soft is ... suboptimal.

Cheers
Jeanette