Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception for Popup Menu with round = 0 and shadeWidth = 0 #87

Closed
carlwitt opened this issue Feb 19, 2014 · 1 comment
Closed

Exception for Popup Menu with round = 0 and shadeWidth = 0 #87

carlwitt opened this issue Feb 19, 2014 · 1 comment
Assignees

Comments

@carlwitt
Copy link

I was facing the non transparent shadows issue (#79) for menus.
Trying to remove both shade and rounded corners causes some dimensions to become negative.

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0
    at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1016)
    at java.awt.image.BufferedImage.<init>(BufferedImage.java:340)
    at com.alee.utils.NinePatchUtils.createShadeIcon(NinePatchUtils.java:86)
    at com.alee.utils.NinePatchUtils.getShadeIcon(NinePatchUtils.java:65)
    at com.alee.laf.menu.WebPopupPainter.paintShade(WebPopupPainter.java:478)
    at com.alee.laf.menu.PopupMenuPainter.paintTransparentPopup(PopupMenuPainter.java:53)
    at com.alee.laf.menu.PopupMenuPainter.paintTransparentPopup(PopupMenuPainter.java:30)
    at com.alee.laf.menu.WebPopupPainter.paint(WebPopupPainter.java:421)
    at com.alee.laf.menu.WebPopupMenuUI.paint(WebPopupMenuUI.java:740)
    at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
    at javax.swing.JComponent.paintComponent(JComponent.java:778)
    at javax.swing.JComponent.paint(JComponent.java:1054)
    at javax.swing.JComponent.paintChildren(JComponent.java:887)
    at javax.swing.JComponent.paint(JComponent.java:1063)
    at javax.swing.JLayeredPane.paint(JLayeredPane.java:585)
    at javax.swing.JComponent.paintToOffscreen(JComponent.java:5219)
    at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1529)
    at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1452)
    at javax.swing.RepaintManager.paint(RepaintManager.java:1249)
    at javax.swing.JComponent._paintImmediately(JComponent.java:5167)
    at javax.swing.JComponent.paintImmediately(JComponent.java:4978)
    at javax.swing.RepaintManager$3.run(RepaintManager.java:808)
    at javax.swing.RepaintManager$3.run(RepaintManager.java:796)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:796)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:769)
    at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:718)
    at javax.swing.RepaintManager.access$1100(RepaintManager.java:62)
    at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1677)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

My code

// initialize menu, works well
WebMenuBar menuBar = new WebMenuBar ();
setupMenuBar ( menuBar );
WebMenu fileMenu = (WebMenu) menuBar.getMenu(0);
WebPopupMenuUI popupMenu = (WebPopupMenuUI) fileMenu.getPopupMenu().getUI();

// set round and shade, causes error when both options are set to zero
popupMenu.setRound(0);
popupMenu.setShadeWidth(0);

And, though I don't think the error has something to do with it, the setup code for the menu.

public void setupMenuBar ( WebMenuBar menuBar )
{
    menuBar.add ( new WebMenu ( "File") {
        {
            add ( new WebMenuItem ( "Load file") {
                {
                    setAccelerator ( Hotkey.CTRL_O );
                    addActionListener(new FileLoadAction());
                }
            } );
        }
    } );
}
@mgarin mgarin added this to the Small issues milestone Feb 19, 2014
@mgarin mgarin self-assigned this Feb 19, 2014
@mgarin
Copy link
Owner

mgarin commented Feb 19, 2014

Thanks for reporting and especially for the simple example that represents this issue!
There was indeed a small bug with shade paint method.
Fix will be available in v1.27 version.

I have also made a lot of changes to menu code and corner will now display properly even when shadeWidth is less than cornerWidth (that was also an issue in old version).

mgarin added a commit that referenced this issue Feb 21, 2014
#86 - WebFileDrop settings and selected files fix
#85 - WebRootPaneUI maximize is now disabled on title double-click when maximize button is hidden
Major improvements in StyleManager and skin installation behavior
Default style painters are now also custom and moved into separate skin package
Redundant PainterMethods interface and its implementations removed
From now on all specific style settings will be contained inside painters only
PanelPainter support added, WebPanel and WebPanelUI classes upgraded
NinePatchIcon painting within custom bounds fixed
WebScrollBarUI preferred size fix
@mgarin mgarin closed this as completed Feb 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants