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

JWindow and JToolTip How to achieve backdrop transparent ? #705

Closed
Link-Kou opened this issue Aug 2, 2023 · 8 comments
Closed

JWindow and JToolTip How to achieve backdrop transparent ? #705

Link-Kou opened this issue Aug 2, 2023 · 8 comments
Milestone

Comments

@Link-Kou
Copy link

Link-Kou commented Aug 2, 2023

image

macOS: JWindow and JToolTip backdrop not transparent

@DevCharly
Copy link
Collaborator

Sorry, but I've no idea what you're doing... 😕

Is this even related to FlatLaf?
Tooltips are not rounded on macOS with FlatLaf.

@Link-Kou
Copy link
Author

Link-Kou commented Aug 2, 2023

image image

JDK version:JDK17
flatlaf version: 3.1.1
Yes, when I open the style, JWindow has an extra background color.

@DevCharly

@DevCharly
Copy link
Collaborator

What does it look like without FlatLaf?
E.g. with Metal or Aqua L&F.

@Link-Kou
Copy link
Author

Link-Kou commented Aug 2, 2023

When there is no flatlaf, the background can be transparent normally

@DevCharly
Copy link
Collaborator

When there is no flatlaf, the background can be transparent normally

Do you have a screenshot?

@Link-Kou
Copy link
Author

Link-Kou commented Aug 3, 2023

2023-08-03_09-05-40 (2)

@DevCharly

@DevCharly
Copy link
Collaborator

Finally, I realized what you mean 😔 : a JWindow with transparent background is not shown transparent on macOS

Test case to reproduce:

import java.awt.Color;
import javax.swing.*;
import javax.swing.border.LineBorder;
import com.formdev.flatlaf.FlatLightLaf;

public class WindowTest
{
    public static void main( String[] args ) {
        SwingUtilities.invokeLater( () -> {
            FlatLightLaf.setup();

            JLabel label = new JLabel( "text" );
            label.setBorder( new LineBorder( Color.red ) );

            JWindow window = new JWindow();
            window.setBackground( new Color( 0, 0, 0, 0 ) );
            window.add( label );
            window.setBounds( 50, 50, 200, 200 );
            window.setVisible( true );
        } );
    }
}

On macOS this shows gray window with drop shadow:

image

On Windows it works and does not show window border or background:

image

The reason seems to be that FlatLaf sets background color for root pane here:

c.setBackground( UIManager.getColor( "RootPane.background" ) );

To workaround this issue make the root pane also transparent:

_jWindow.getRootPane().setBackground(new Color(0, 0, 0, 0));

Anyway, I'll fix this issue soon...

DevCharly added a commit that referenced this issue Jan 28, 2024
…nt color (alpha < 255) did not show the window translucent (issue #705)
@DevCharly
Copy link
Collaborator

fixed in latest 3.4-SNAPSHOT: https://github.com/JFormDesigner/FlatLaf#snapshots

@DevCharly DevCharly added this to the 3.4 milestone Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants