简体   繁体   中英

Javafx Removing a node from htmleditor

I have a simple application developed in javafx. The problem is that I want to remove the two tool bars but find no way how to do that. Here in the code I have set the visibility of the bottom toolbar to false. For help if you need to answer: The id of the top toolbar is .top-toolbar while the id of the bottom toolbar is .bottom-toolbar. Your help will be appreciated greatly... Here is my code. Thanks in advance.

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

apply the following code on your 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM