mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.13k stars 234 forks source link

Custom window decoration blocks events on JRootPane outside of decoration shape #636

Closed mgarin closed 3 years ago

mgarin commented 3 years ago

Due to how AbstractDecorationPainter.contains ( ... ) method is implemented and the fact that it is reused for RootPanePainter implementation - any events on JRootPane that occur outside of the decoration shape specified in rootpane style are completely ignored.

Usually it isn't noticeable, but it does cause issues for some components that might be displayed within the JRootPane (on layered pane), like JComboBox. Here is an example:

image

In this case it is impossible to select 3rd item in the popup menu with mouse.

Example code:

public class Example
{
    public static void main ( final String[] args )
    {
        SwingUtilities.invokeLater ( new Runnable ()
        {
            @Override
            public void run ()
            {
                WebLookAndFeel.install ();

                final WebFrame frame = new WebFrame ( StyleId.frameDecorated );
                frame.setLayout ( new FlowLayout () );
                frame.add ( new JComboBox ( new String[]{ "1", "2", "3" } ) );
                frame.setDefaultCloseOperation ( WindowConstants.EXIT_ON_CLOSE );
                frame.pack ();
                frame.setLocationRelativeTo ( null );
                frame.setVisible ( true );
            }
        } );
    }
}

This requires a small fix in RootPanePainter implementation.

mgarin commented 3 years ago

Fixed, will be available in v1.2.14 update.