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

Multi-line Tooltip positioning #333

Closed
Chrriis opened this issue May 31, 2021 · 3 comments
Closed

Multi-line Tooltip positioning #333

Chrriis opened this issue May 31, 2021 · 3 comments
Milestone

Comments

@Chrriis
Copy link
Contributor

Chrriis commented May 31, 2021

Hi all!

We have multiline tooltips that can be huge.
In our windows L&F implementation, we have a multi-line implementation of BasicToolTipUI and we rely on the Look & Feel to place the tooltip. The tooltip can occupy a certain amount of space, sometimes even appearing under the mouse, but the beginning of the tooltip is always on screen.
When switching to FlatLaf, it seems to always place such huge tooltip above:
MultiLineTooltips

I think the strategy should be reviewed to always show the beginning of the tooltip (essentially forcing the x and y positions to 0 when they become negative). Having the bottom of the tooltip is useless (main information is generally first in tooltip).

Sample test case:

public static void main(String[] args) throws Exception {
	UIManager.setLookAndFeel(new FlatLightLaf());
	JFrame frame = new JFrame();
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	JPanel centerPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
	centerPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
	JLabel label = new JLabel("A label with a tooltip");
	StringBuilder tooltipSB = new StringBuilder();
	for(int i=0; i<100; i++) {
		if(i > 0) {
			tooltipSB.append('\n');
		}
		tooltipSB.append("Tooltip line ").append(i + 1);
	}
	label.setToolTipText(tooltipSB.toString());
	centerPane.add(label);
	frame.getContentPane().add(centerPane);
	frame.setSize(400, 300);
	frame.setLocationByPlatform(true);
	frame.setVisible(true);
}
@DevCharly
Copy link
Collaborator

Yes, that is not optimal...
Will rework it...

BTW I love those short code snippets to reproduce issues.
This makes it much easier to reproduce problems 👍 👍 👍

@Tyluur
Copy link

Tyluur commented Jun 3, 2021

Yes, that is not optimal...
Will rework it...

BTW I love those short code snippets to reproduce issues.
This makes it much easier to reproduce problems 👍 👍 👍

As do I. +1

@DevCharly
Copy link
Collaborator

fixed in main branch

@DevCharly DevCharly added this to the 1.3 milestone Jun 12, 2021
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

3 participants