How to hide the controls of HTMLEditor?

前端 未结 10 696
日久生厌
日久生厌 2020-12-10 12:45

is it possible to hide the controls of a HTMLEditor above the actual text? (Alignment, Copy&Paste icons, stylings etc.)

Thanks for any help

10条回答
  •  一向
    一向 (楼主)
    2020-12-10 13:19

    If someone really wants to use an unsupported way to hide the Toolbars then there is an even easier way to achieve this (I haven't tested if this causes any problems in the HTMLEditor control so use this at your own risk).

    package htmleditorsample;
    
    import javafx.application.Application;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.layout.Pane;
    import javafx.scene.web.HTMLEditor;
    import javafx.stage.Stage;
    
    public class HTMLEditorSample extends Application {
    
        public static void main(String[] args) {
            launch(args);
        }
    
        @Override
        public void start(Stage primaryStage) {
            final HTMLEditor htmlEditor = new HTMLEditor();
            primaryStage.setScene(new Scene(htmlEditor));
            primaryStage.show();
    
            for (Node toolBar = htmlEditor.lookup(".tool-bar"); toolBar != null; toolBar = htmlEditor.lookup(".tool-bar")) {
                ((Pane) toolBar.getParent()).getChildren().remove(toolBar);
            }
        }
    }
    

提交回复
热议问题