JavaFX HTML Editor

0

JavaFX HTML Editor Tutorials:

The JavaFX HTML Editor is a full functional rich text editor.

We can say it is a application which we including in our JavaFX application.

Features of html editor:

  • Copying and pasting
  • Text formatting
  • Text alignment
  • Paragraph settings such as format, font family, and font size
  • Numbered lists
  • Foreground and background colors
  • Adding a horizontal rule etc.

Constructors :

HTMLEditor()

Creates a new instance of the HTMLEditor control.

Creating HTMLEditor :

To create new HTMLEditor

HTMLEditor htmleditor = new HTMLEditor();

We use the setHtmlText(String htmlText) method

To sets the HTML content of the editor.

For example

htmleditor.setHtmlText(
" different GUI in java "+
"

    • JavaFX
    • JavaSwing
    • AWT

“);

IT look like

Example of html editor:


package javafxtuts;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;

public class Javafxtuts extends Application {

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

  @Override
  public void start(Stage stage) {
      stage.setTitle("Javafxtuts.com");
	//creating HTMLEditor 
      HTMLEditor htmlEditor = new HTMLEditor();
      VBox root =new VBox();
      root.setPadding(new Insets(20, 10, 10, 10));
      root.getChildren().addAll(htmlEditor);
        Scene scene = new Scene(root, 250, 200);
        stage.setScene(scene);
        stage.show();
  }
}

Output :

Share.

Leave A Reply