LookAndFeelFactory.installJideExtension() problem

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.

LookAndFeelFactory.installJideExtension() problem

Postby tolask » Fri Jul 13, 2007 8:03 am

Dear all,

i'm currently evaluating JIDE common components... and I have the following problem.

Whenever I :
- use the extensions : LookAndFeelFactory.installJideExtension()
- use a popup menu which contains only 1 item (which popup item)

I have the following exception :

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width (0) and height (1) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
at java.awt.image.BufferedImage.<init>(BufferedImage.java:323)
at com.jidesoft.icons.IconsFactory.createGrayImage(Unknown Source)
at com.jidesoft.plaf.vsnet.VsnetMenuItemUI.paintIcon(Unknown Source)
at com.jidesoft.plaf.vsnet.VsnetMenuItemUI.paintMenuItem(Unknown Source)
at com.jidesoft.plaf.vsnet.VsnetMenuItemUI.paint(Unknown Source)
at com.jidesoft.plaf.vsnet.VsnetMenuItemUI.update(Unknown Source)
at javax.swing.JComponent.paintComponent(JComponent.java:742)
at javax.swing.JComponent.paint(JComponent.java:1005)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


As soon as I disable the extensions, everything is ok...

Any idea ?


Thanks you all
tolask
 
Posts: 37
Joined: Fri Jul 13, 2007 7:55 am

Postby JIDE Support » Fri Jul 13, 2007 8:08 am

It looks like the icon has the problem. Do you have a test case for it?
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby tolask » Tue Jul 17, 2007 5:01 am

Unfortunately, I could not reproduce the problem in a simple test case application... and mine is too large to post it here. But for your information, I also noticed that the problem only occurs when the XP look is set to "Windows Classic Style"... When set XP style, everything is ok.

Here is a screen of the popup menu (XP Style) :

Image

Thanks again
tolask
 
Posts: 37
Joined: Fri Jul 13, 2007 7:55 am

Postby JIDE Support » Tue Jul 17, 2007 8:49 am

That's strange. We certainly tested on Windows classic theme. Can you try to debug it yourself? We can't do without a test case. As you have the whole source code, it shouldn't be hard for you to debug into JIDE Common Layer source code and figure out why the image size is empty.

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

Postby tolask » Wed Jul 18, 2007 1:19 am

Ok, I did a small debug session on the Common Layer and found the problem in the following source (com.jidesoft.icons.IconsFactory):

Code: Select all
public static ImageIcon createGrayImage(Component c, Icon icon) {
        if (icon == null)
            return EMPTY_ICON;
        BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
        icon.paintIcon(c, image.getGraphics(), 0, 0);
        return new ImageIcon(GrayFilter.createDisabledImage(image));
}


It appears that the BufferedImage constructor fires an exception when the width or height equals zero. I change the code to this:

Code: Select all
public static ImageIcon createGrayImage(Component c, Icon icon) {
        if (icon == null)
            return EMPTY_ICON;
       
        int w = icon.getIconWidth(), h = icon.getIconHeight();
        if ((w == 0) || (h == 0))
            return EMPTY_ICON;
       
        BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
        icon.paintIcon(c, image.getGraphics(), 0, 0);
        return new ImageIcon(GrayFilter.createDisabledImage(image));
}


and it now works. Note that I'm using JDK 1.5.0_06.

Please also note that I found another display problem related to zero sized icons in the VsnetMenuItemUI class. As you see in the screen attached here above, the text is not correctly displayed. Here is what I changed in the layoutMenuItem(...) method to make it work:

Code: Select all
      // Put this at the very beginning of the method's source code
      if (icon != null)
          if ((icon.getIconHeight() == 0) || (icon.getIconWidth() == 0)) icon = null;



Thanks for helping me to fix this, and... hoping those changes will be incorporated in a future Common Layer release.e

Best regards,

Thomas
tolask
 
Posts: 37
Joined: Fri Jul 13, 2007 7:55 am

Postby JIDE Support » Wed Jul 18, 2007 7:15 am

Feel free to check it in directly to JIDE Common Layer. I can grant you permission if you don't have.

May I ask why the icon is zero size?

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

Postby tolask » Wed Jul 18, 2007 8:26 am

Hi,

No it seems I don't have sufficient permissions to change the code. Can you grant them please?

The zero sized icon is in another 3rd party library I use, and as far as I know, it's to "simplify" all the methods that are called on menus to compute the ideal format, size, etc... I really do agree that it's not "best practice" but it will be cool to remove an error case from JIDE to make it even more robust :-)

Best regards

Thomas
tolask
 
Posts: 37
Joined: Fri Jul 13, 2007 7:55 am

Postby JIDE Support » Wed Jul 18, 2007 8:29 am

Sure. What is your dev.java.net's user id? Or you can ask for developer permission from the project page and I will get an email notification.

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 10 guests

cron