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

Tool tip shadow not transparent when over heavyweight component #626

Closed
rkeen-siemens opened this issue Dec 9, 2022 · 3 comments
Closed
Milestone

Comments

@rkeen-siemens
Copy link

When a tooltip is displayed over a heavyweight component the shadow is on a white background rather than transparent.
Within Window Bounds

If the tooltip is partly outside the bounds of the main window, it is rendered as expected.
Outside Window Bounds

I suspect this is due to the fact that the PopupFactory is not forcing a heavyweight component when the popup will be displayed over a heavyweight component. This is probably a general issue in Swing but it is not seen there since the default tool tip popup doesn't have a drop shadow. Since FlatLaf returns a DropShadowPopup it becomes an issue.

I understand I can disable the drop shadow (via "Popup.dropShadowPainted") or force heavy weight popups (via "Popup.forceHeavyWeight"), but it would be nice if this worked out of the box. Perhaps force a heavy weight popup if there are heavyweight components at the extents of the tool tip?

Here's the source to reproduce. This seems to be an issue on Windows, but not Linux (didn't try Mac).

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JButton;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import com.formdev.flatlaf.FlatLightLaf;

public class Form extends javax.swing.JFrame {
	public Form() {
		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		setTitle("Tool Tip Over Heavyweight");
		getContentPane().setLayout(new BorderLayout(4, 4));

		JButton lightweight = new JButton("Lightweight");
		lightweight.setToolTipText("Lightweight");
		getContentPane().add(lightweight, BorderLayout.PAGE_START);

		Button heavyweight = new Button("Heavyweight");
		heavyweight.setBackground(Color.BLACK);
		heavyweight.setForeground(Color.YELLOW);
		getContentPane().add(heavyweight, BorderLayout.CENTER);
		setMinimumSize(new Dimension(150, 200));
		setLocationRelativeTo(null);
		pack();
	}

	public static void main(String args[]) {
		FlatLightLaf.setup();
		SwingUtilities.invokeLater(() -> new Form().setVisible(true));
	}
}
@DevCharly
Copy link
Collaborator

At the moment I would recommend to force heavyweight popups for your application:

UIManager.put( "Popup.forceHeavyWeight", true );

Lightweight popups are only used on Windows and only if the popup fits into the window.
On macOS and on Linux, always heavyweight popups are used because they provide operating system border and drop shadow.

...but it would be nice if this worked out of the box. Perhaps force a heavy weight popup if there are heavyweight components at the extents of the tool tip?

I'll try this...

BTW working a way to use popups with native borders and drop shadow on Windows 11:

image image image

Then also heavyweight popup will be used on Windows 11.
Only Window 10 will use lightweight popups.

DevCharly added a commit that referenced this issue Sep 2, 2023
@DevCharly
Copy link
Collaborator

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

@DevCharly DevCharly added this to the 3.3 milestone Sep 2, 2023
@DevCharly
Copy link
Collaborator

fixed in FlatLaf 3.2.1

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