【问题标题】:Javafx Removing a node from htmleditorJavafx 从 htmleditor 中删除一个节点
【发布时间】:2014-12-14 07:45:29
【问题描述】:

我有一个用 javafx 开发的简单应用程序。问题是我想删除两个工具栏,但找不到怎么做。在代码中,我将底部工具栏的可见性设置为 false。 如果您需要回答,请寻求帮助:顶部工具栏的 id 是 .top-toolbar,而底部工具栏的 id 是 .bottom-toolbar。您的帮助将不胜感激......这是我的代码。 提前致谢。

import javafx.application.Application;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;

public class PrivateHistory extends Application {

    @Override
    public void start(Stage stage) {
        stage.setTitle("HTMLEditor Sample");
        stage.setWidth(400);
        stage.setHeight(300);   
        final HTMLEditor htmlEditor = new HTMLEditor();
        htmlEditor.setPrefHeight(245);
        Scene scene = new Scene(htmlEditor);
        stage.setScene(scene);
        Node node = htmlEditor.lookup(".bottom-toolbar");
        node.setVisible(false);
        //htmlEditor.setHtmlText("<img src='"+getClass().getResource("ball.png")+"' />");
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
} 

【问题讨论】:

  • 谢谢大佬,很高兴帮你解决问题:)

标签: java html css javafx


【解决方案1】:

在您的htmlEditor 上应用以下代码

    htmlEditor.lookup(".top-toolbar").setManaged(false);
    htmlEditor.lookup(".top-toolbar").setVisible(false);

    htmlEditor.lookup(".bottom-toolbar").setManaged(false);
    htmlEditor.lookup(".bottom-toolbar").setVisible(false);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-31
    • 1970-01-01
    • 2011-06-06
    • 2012-09-18
    • 2017-03-04
    相关资源
    最近更新 更多