Friday, May 11, 2012
Create your own HTML Editor in JavaFX2.1
In JavaFX 2.1, the class javafx.scene.web.HTMLEditor is a control that allows for users to edit text, and apply styling to this text. The underlying data model is HTML, although this is not shown visually to the end-user.
Example:
Next: - Obtain content of HTMLEditor
Example:
package javafx_html;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.GroupBuilder;
import javafx.scene.Scene;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;
/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaFX_HTMLeditor extends Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");
Group root = new Group();
final HTMLEditor htmlEditor = new HTMLEditor();
Group myGroup = GroupBuilder.create()
.children(htmlEditor)
.build();
root.getChildren().add(myGroup);
primaryStage.setScene(new Scene(root, 500, 400));
primaryStage.show();
}
}
Next: - Obtain content of HTMLEditor
Subscribe to:
Post Comments (Atom)
2 comments:
Could you please extend this example showing how to save the resulting HTML to a file?
Reply Deletehello,
Deleteplease read Save HTMLEditor generated code in file.