Saltar la navegación

Editor HTML

El editor HTML es un control que nos ofrece todas las características de un editor de código HTML que produce código en HTML5. Como tal, nos ofrece la posibilidad de formatear texto, párrafos, listas, etc.

El editor HTML pertenece a la clase javafx.scene.web.HTMLEditor.

La siguiente imagen muestra el aspecto del editor HTML.

El código utilizado para crear esta interfaz es el siguiente:

package javafx.controles;

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 EditorHTML extends Application {

	@Override
	public void start(Stage escenarioPrincipal) {
		try {
			VBox raiz = new VBox();
			raiz.setPadding(new Insets(40));
			raiz.setSpacing(10);
			
			HTMLEditor editor = new HTMLEditor();
			
			raiz.getChildren().addAll(editor);
			
			Scene escena = new Scene(raiz, 750, 400);
			escenarioPrincipal.setTitle("Editor HTML");
			escenarioPrincipal.setScene(escena);
			escenarioPrincipal.show();
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

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

}