【问题标题】:Tooltip using html javafx使用 html javafx 的工具提示
【发布时间】:2013-12-31 01:52:10
【问题描述】:

我想在 javafx 的复选框上添加工具提示。我想用java代码来做。此工具提示文本取决于某些对象属性。我的问题是我想在工具提示中加粗一些(不是全部)单词。有什么办法吗?据我用谷歌搜索,我没有找到解决方案或使用例如 html 的方法。 如果我能做这样的事情,那将是一种魅力:

PaggingTest paggingTest = new PaggingTest();
Tooltip tooltip = new Tooltip(
    "<b>AlgorithmType:</b> " + paggingTest.getAlgorithmType()
    + "<br/><b>Memory Pages:</b> " + paggingTest.getMemoryPages()
    + "<br/><b>Program Pages:</b> " + paggingTest.getProgramPages()
    + "<br/><b>Sample Count:</b> " + paggingTest.getSampleCount()
    + "<br/><b>Distribution Type:</b> " + paggingTest.getDistributionType());

CheckBox checkBox = new CheckBox("Test");
checkBox.setTooltip(tooltip);
testFlowPane.getChildren().add(checkBox);

【问题讨论】:

    标签: java html styles javafx tooltip


    【解决方案1】:

    你可以试试这个:

    WebView  web = new WebView();
    WebEngine webEngine = web.getEngine();
    webEngine.loadContent
    (
        "<b>AlgorithmType:</b> " + paggingTest.getAlgorithmType()
        + "<br/><b>Memory Pages:</b> " + paggingTest.getMemoryPages()
        + "<br/><b>Program Pages:</b> " + paggingTest.getProgramPages()
        + "<br/><b>Sample Count:</b> " + paggingTest.getSampleCount()
        + "<br/><b>Distribution Type:</b> " + paggingTest.getDistributionType()
    );
    
    Tooltip  tip = new Tooltip();
    tip.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
    tip.setGraphic(web);
    

    您可能需要对 webview 应用一些 css 样式以使其与您的提示融为一体。

    【讨论】:

    • 非常有帮助!我可以添加 css 并给出我想要的样式。非常感谢你。 +1
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-23
    • 2015-03-02
    • 2014-07-04
    • 2021-02-11
    • 1970-01-01
    • 2015-08-24
    相关资源
    最近更新 更多