[英]How to get the IDs of nodes inside HTMLEditor, JavaFX
我希望从HTMLEditor中删除一些控制按钮,因为我不需要它们。 为此,我需要到达所需的节点。 我怎么知道HTMLEditor里面的节点ID? 请参阅以下内容。 谢谢!
public class myApp extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("myApp.fxml")); //this fxml has HTMLEditor named htmlEditor.
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
Node someControlInsideHtmlEditor = root.lookup("#htmlEditor").lookup("#what_Is_The_ID_of_This_someControlInsideHtmlEditor")
}
}
ScenicView.show(场景);
例如,打开HTMLEditor - > ToolBar - > HBox,然后选择第一个Button。 查看右侧“节点详细信息”中的“styleClass”。 你需要“html-editor-cut”。 它可以与此代码一起使用:
Button cutButton =(Button)root.lookup(“。html-editor-cut”);
不知道你是否还在寻找这个答案。 在Java 8中,HTMLEditor只有一个子节点,它是一个GridPane。 前两个孩子是ToolBars,第三个是WebView。 从网格窗格中删除前两个子项以执行所需的格式设置。 这有帮助吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.