0
有沒有在源代碼模式下使用javaFx HTMLEditor
的方法,就像在Firefox中選擇顯示源代碼一樣?javafx中的HTML源代碼HTMLEditor
我需要這個,因爲我想加載在編輯器中包含xml標籤的字符串,並且wigdet沒有顯示它們。
有沒有在源代碼模式下使用javaFx HTMLEditor
的方法,就像在Firefox中選擇顯示源代碼一樣?javafx中的HTML源代碼HTMLEditor
我需要這個,因爲我想加載在編輯器中包含xml標籤的字符串,並且wigdet沒有顯示它們。
不是HTMLEditor也不是Web引擎或Webview包含您的需要的方法。我發現的唯一的東西是在不同的textarea中顯示html。也許這會幫助你。
import javafx.application.Application;
import javafx.event.Event;
import javafx.event.EventType;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;
public class JavaFXApplication1 extends Application {
@Override
public void start(Stage primaryStage) {
HTMLEditor editor = new HTMLEditor();
editor.setHtmlText("<html>"
+ "<head>"
+ "<title>A Test</title>"
+ "</head>"
+ "<body>This is just a Test</body>"
+ "</html>");
TextArea area = new TextArea();
area.setText(editor.getHtmlText());
editor.addEventHandler(EventType.ROOT, (Event event) -> {
area.setText(editor.getHtmlText());
});
VBox root = new VBox();
VBox.setVgrow(area, Priority.ALWAYS);
root.getChildren().addAll(editor, area);
Scene scene = new Scene(root, 300, 250);
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}