1

我有这个问题:标签(JLabel)的工具提示被 BrowserView 隐藏。工具提示正确显示在任何其他 java 组件的顶部,但被 BrowserView 隐藏。我想要的是使工具提示在 BrowserView 顶部可见。任何人都知道它的原因以及使工具提示可见的方法。

生成的 UI 以及如何隐藏工具提示附在此处。

代码示例:

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);
  }
}

结果 UI:右面板是一个 BrowserView,它隐藏了左面板标签的工具提示

在此处输入图像描述

4

2 回答 2

0

让大家知道,这样做的原因是 JXBrowser 是 1.6.17 并且默认情况下它是重量级的。Jtooltip 是 LightWeight。因为 Jtooltip 没有出现在重量级浏览器的顶部。

很少有解决方案。1. 使浏览器轻量级 (com.teamdev.jxbrowser.chromium.BrowserType#LIGHTWEIGHT) 2. 使工具提示 HeavyWeight

于 2018-01-26T03:43:28.720 回答
0

getToolTipLocation()您可以在特定位置覆盖和设置工具提示文本(定义 x 和 y 坐标):

class BrowserLabel extends JLabel {

    public BrowserLabel(String text) {
        setText(text);
    }

    @Override
    public Point getToolTipLocation(MouseEvent e) {
        return new Point(x, y);
    }
}
于 2019-12-11T12:27:20.907 回答