Reputation: 11
I have this problem: tooltip of the label (JLabel) is hidden by a BrowserView. The tooltip properly shown top of any other java component, but gets hidden by BrowserView. What I want is to make the tooltip visible on top of BrowserView. Anyone knows the reason for it and a way to get the tooltip visible.
Resulted UI and how tooltip is hidden is attached here.
Code sample:
public class TestFrame
{
public static void main (String args[])
{
JSplitPane splitPane = new JSplitPane();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel topPanel = new JPanel();
topPanel.setBorder(new LineBorder(Color.black));
topPanel.setSize(75, 75);
JLabel label = new JLabel("TestLabel");
label.setToolTipText("Test Tooltip 1");
topPanel.add(label);
splitPane.setLeftComponent(topPanel);
Browser browser = new Browser();
BrowserView browserView = new BrowserView(browser);
splitPane.setRightComponent(browserView);
browser.loadURL("http://www.google.com");
frame.add(splitPane);
frame.setSize(700, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Result UI: Right panel is a BrowserView which hides the Tooltip of left panel label
Upvotes: 1
Views: 168
Reputation: 1
You can override getToolTipLocation()
and set tooltip text at a particular location (define x and y coordinates):
class BrowserLabel extends JLabel {
public BrowserLabel(String text) {
setText(text);
}
@Override
public Point getToolTipLocation(MouseEvent e) {
return new Point(x, y);
}
}
Upvotes: 0
Reputation: 11
To let all know, the reason for this is JXBrowser is of 1.6.17 and it comes as Heavyweight by default. And the Jtooltip is LightWeight. because of that Jtooltip is does not appear on top of the Heavyweight browser.
Few solutions. 1. Make the Browser lightweight (com.teamdev.jxbrowser.chromium.BrowserType#LIGHTWEIGHT) 2. Make the Tooltip HeavyWeight
Upvotes: 0