JideButton and JMenu JMenuBar under WindowsLookAndFeel

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby EyalKatz » Mon Jan 10, 2011 1:31 am

Hi all,

It seems that using JideButton somehow messes up the L&F of JMenu and JMenuBar under Windows Look and Feel
Adding a single JideButton *anywhwre* in your JFrame makes all JMenuItems display a wierd 'V' left to their text

Here's a sample code (uncomment the button creation to see the correct behavior)

Code: Select all
    public static void main(String[] args) throws Exception {
        UIManager.setLookAndFeel(new WindowsLookAndFeel());

        JMenu mnuFile = new JMenu("File");
        JMenuItem open = new JMenuItem("Save");
        mnuFile.add(open);

        JideButton aButton = new JideButton("A JideButton - note the V in the menu item");
        //JButton aButton = new JButton("A JButton");

        JMenuBar menubar = new JMenuBar();
        menubar.add(mnuFile);
        JFrame fr = new JFrame("JideButton issue");
        fr.setJMenuBar(menubar);
        fr.getContentPane().add(aButton);
        fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        fr.pack();
        fr.setVisible(true);
    }


here's a screenshot od the problem:
http://dl.dropbox.com/u/14766452/techs/ ... button.png

And a screenshot of a correct behavior using JButton:
http://dl.dropbox.com/u/14766452/techs/jide/jbutton.png


Anyone knows is that's a bug/feature/workaround?

Thanks

Eyal
EyalKatz
 
Posts: 5
Joined: Mon Jun 27, 2005 4:14 am

Re: JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby JIDE Support » Mon Jan 10, 2011 3:30 pm

It's caused by our attempt to install UIDefaults for JIDE components. You could explicitly install LookAndFeelFactory.VSNET_STYLE_WITHOUT_MENU to disable the behavior. The modified test case is posted below FYI.
Code: Select all
    public static void main(String[] args) throws Exception {
        UIManager.setLookAndFeel(new WindowsLookAndFeel());
        LookAndFeelFactory.installJideExtension(LookAndFeelFactory.VSNET_STYLE_WITHOUT_MENU);

        JMenu mnuFile = new JMenu("File");
        JMenuItem open = new JMenuItem("Save");
        mnuFile.add(open);

        JideButton aButton = new JideButton("A JideButton - note the V in the menu item");
        //JButton aButton = new JButton("A JButton");

        JMenuBar menubar = new JMenuBar();
        menubar.add(mnuFile);
        JFrame fr = new JFrame("JideButton issue");
        fr.setJMenuBar(menubar);
        fr.getContentPane().add(aButton);
        fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        fr.pack();
        fr.setVisible(true);
    }    //

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby EyalKatz » Mon Jan 10, 2011 11:55 pm

Thanks for the reply.

However, this is a very partial solution - as you can, I lost the cool orange-yellow styling on the JideButton.
http://dl.dropbox.com/u/14766452/techs/ ... o_menu.png

But that's not over - turns out you can't have a JMenuItem with an icon if you're in the VSNET mode:
Try adding an ImageIcon to the JMenuItem in my original code - it will show that terrible 'V' instead
This is solved by installing the VSNET_STYLE_WITHOUT_MENU extension, but then again - you pay with asthetic.

I would consider such a problem a bug.
EyalKatz
 
Posts: 5
Joined: Mon Jun 27, 2005 4:14 am

Re: JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby JIDE Support » Tue Jan 11, 2011 12:44 pm

What is you JIDE version and OS? I can't see to be able to reproduce it on the latest version on both XP and Win7.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby EyalKatz » Wed Jan 12, 2011 2:51 am

I'm using the latest jide-oss-2.9.7 jar (downloaded and linked again for making sure)

My env. spec is:
os.name=Windows Vista (That's Windows 7)
os.arch=x86
os.version=6.1
java.version=1.6.0_10

As can be seen here:
http://dl.dropbox.com/u/14766452/techs/jide/env.png

Thanks for the help, I'd really appreciate a workaround if exists (otherwise I'm stuck with the boring blue button theme)

Eyal
EyalKatz
 
Posts: 5
Joined: Mon Jun 27, 2005 4:14 am

Re: JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby JIDE Support » Wed Jan 12, 2011 3:39 pm

Actually the check box is painted by WindowsMenuItemUI. The reason is that, the UI defaults were re-configured when you instantiate JideButton. The workaround is as easy as that you install JIDE extension before you create any menu components.
Code: Select all
    public static void main(String[] args) throws Exception {
        LookAndFeelFactory.installDefaultLookAndFeel();
        LookAndFeelFactory.installJideExtension();
        JMenu mnuFile = new JMenu("File");
        JMenuItem open = new JMenuItem("Save");
        mnuFile.add(open);

        JideButton aButton = new JideButton("A JideButton - note the V in the menu item");
        //JButton aButton = new JButton("A JButton");


        JMenuBar menubar = new JMenuBar();
        menubar.add(mnuFile);
        JFrame fr = new JFrame("JideButton issue");
        fr.setJMenuBar(menubar);
        fr.getContentPane().add(aButton);
        fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        fr.pack();
        fr.setVisible(true);
    }

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby EyalKatz » Thu Jan 13, 2011 12:31 am

That worked, thanks.

Two notes:

1.
For some reason, the JMenu is opaque, leading to a grayish background in the menubar, you should call setOpaue(false) on it
Here's a screenshot with the problem: http://dl.dropbox.com/u/14766452/techs/jide/opaque.png
(This is GUI we're talking here, not server-logs, everything should be tip-top)
Is it a bug? or did I miss anything?

2.
I think the framework should warn (log4j-warn/stdout/anything) that a call to LookAndFeelFactory.installJideExtension() was made After components have been initilized.
It shouldn't be too difficult, and would save us from unpolished UI and posts like this...

Please reply.

Thanks for the help: all and all - Jide truly rocks.

Eyal
EyalKatz
 
Posts: 5
Joined: Mon Jun 27, 2005 4:14 am

Re: JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby JIDE Support » Thu Jan 13, 2011 8:30 am

It is a compatible issue. If you are using JideMenu, it will look okay.

Not possible. We call installJideExtention automatically when we find missing UIDefault needed by JIDE. However we have no idea that some other component has been created before installJideExtension. So if you went through all our demo source code, you will see all of them call installJideExtension right after setting the L&F. If you follow this convention in your application, you will be in good shape.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby EyalKatz » Fri Jan 14, 2011 11:50 am

Fair.

Thanks for all the help!

Eyal
EyalKatz
 
Posts: 5
Joined: Mon Jun 27, 2005 4:14 am

Re: JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby Java1Guy » Wed Feb 02, 2011 12:13 am

I have the exact same symptoms, but no help on the solution...
My variation is this:
creating a JideSplitButton puts check marks as the icon to ALL my menus.
Per the above suggestion I put right in my main:
Code: Select all
   public static void main(final String[] argv) {
     //Unlock the JIDE grids framework
     com.jidesoft.utils.Lm.verifyLicense("***", "---", "therealcode");
     // Seems to be an issue that check boxes are created in each menu without this
     LookAndFeelFactory.installDefaultLookAndFeel();
     LookAndFeelFactory.installJideExtension();
     LookAndFeelFactory.installJideExtension(LookAndFeelFactory.VSNET_STYLE_WITHOUT_MENU);
...

The other thing my code does is:
Code: Select all
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
to set the native Windows LAF...

Ideas?
Thanks, Mark
Java1Guy
 
Posts: 5
Joined: Wed Feb 02, 2011 12:07 am

Re: JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby Java1Guy » Wed Feb 02, 2011 12:21 am

The solution was to use
Code: Select all
     // Seems to be an issue that check boxes are created in each menu without this
     LookAndFeelFactory.installDefaultLookAndFeel();
     LookAndFeelFactory.installJideExtension();

INSTEAD OF
Code: Select all
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

and not in addition to.
Java1Guy
 
Posts: 5
Joined: Wed Feb 02, 2011 12:07 am

Re: JideButton and JMenu JMenuBar under WindowsLookAndFeel

Postby JIDE Support » Wed Feb 02, 2011 10:35 am

Yes, you got it. LookAndFeelFactory.installDefaultLookAndFeel() will configure the UIManager for you.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 7 guests