Java Reference
In-Depth Information
Create an application to dynamically customize border regions using JavaFX's CSS
styling API.
The following code creates an application that has a CSS editor text area and a bor-
der view region surrounding an image. By default the editor's text area will contain
JavaFX styling selectors that create a dashed-blue line surrounding the image. You will
have the opportunity to modify styling selector values in the CSS Editor by clicking the
Bling! button to apply border settings.
primaryStage.setTitle("Chapter 14-8 Generating Borders");
Group root = new Group();
Scene scene = new Scene(root, 600, 330, Color.WHITE);
// create a grid pane
GridPane gridpane = new GridPane();
gridpane.setPadding(new Insets(5));
gridpane.setHgap(10);
gridpane.setVgap(10);
// label CSS Editor
Label cssEditorLbl = new Label("CSS Editor");
GridPane.setHalignment(cssEditorLbl, HPos.CENTER);
gridpane.add(cssEditorLbl, 0, 0);
// label Border View
Label borderLbl = new Label("Border View");
GridPane.setHalignment(borderLbl, HPos.CENTER);
gridpane.add(borderLbl, 1, 0);
// Text area for CSS editor
final TextArea cssEditorFld = new TextArea();
cssEditorFld.setPrefRowCount(10);
cssEditorFld.setPrefColumnCount(100);
cssEditorFld.setWrapText(true);
cssEditorFld.setPrefWidth(150);
GridPane.setHalignment(cssEditorFld, HPos.CENTER);
gridpane.add(cssEditorFld, 0, 1);
String cssDefault = "-fx-border-color: blue;\n"
Search WWH ::




Custom Search