@Override public void start(final Stage stage) throws Exception { StackPane pane = new StackPane(); JFXSpinner root = new JFXSpinner(); pane.getChildren().add(root); final Scene scene = new Scene(pane, 300, 300); scene.getStylesheets().add(MainDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setScene(scene); stage.setTitle("JFX Spinner Demo"); stage.show(); }
StackPane colorPane = new StackPane(); colorPane.setStyle(STYLE); colorPane.getStyleClass().add("red-500"); main.getChildren().add(colorPane); StackPane colorPane1 = new StackPane(); colorPane1.setStyle(STYLE); colorPane1.getStyleClass().add("blue-500"); StackPane placeHolder = new StackPane(colorPane1); placeHolder.setStyle(STYLE); main.getChildren().add(placeHolder); StackPane colorPane2 = new StackPane(); colorPane2.setStyle(STYLE); colorPane2.getStyleClass().add("green-500"); main.getChildren().add(colorPane2); StackPane colorPane3 = new StackPane(); colorPane3.setStyle(STYLE); colorPane3.getStyleClass().add("yellow-500"); main.getChildren().add(colorPane3); StackPane colorPane4 = new StackPane(); colorPane4.setStyle(STYLE); colorPane4.getStyleClass().add("purple-500"); main.getChildren().add(colorPane4); StackPane wizard = new StackPane();
toast.setWrapText(true); toast.setText(message); StackPane toastContainer = new StackPane(toast); toastContainer.setPadding(new Insets(20)); actionContainer = new StackPane(); actionContainer.setPadding(new Insets(0, 10, 0, 0)); return getPrefWidth(); double actionWidth = actionContainer.isVisible() ? actionContainer.getWidth() : 0.0; return prefWidthProperty().get() - actionWidth; }, prefWidthProperty(), actionContainer.widthProperty(), actionContainer.visibleProperty())); action.getStyleClass().add("jfx-snackbar-action"); actionContainer.getChildren().add(action); actionContainer.setVisible(true); actionContainer.setManaged(true); action.setOnAction(actionHandler); } else { actionContainer.setVisible(false); actionContainer.setManaged(false); action.setVisible(false);
public class Test extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { StackPane root = new StackPane(); root.setId("pane"); Scene scene = new Scene(root, 300, 250); scene.getStylesheets().addAll(this.getClass().getResource("style.css").toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); } }
/** Places content in a bordered pane with a title. */ class BorderedTitledPane extends StackPane { BorderedTitledPane(String titleString, Node content) { Label title = new Label(" " + titleString + " "); title.getStyleClass().add("bordered-titled-title"); StackPane.setAlignment(title, Pos.TOP_CENTER); StackPane contentPane = new StackPane(); content.getStyleClass().add("bordered-titled-content"); contentPane.getChildren().add(content); getStyleClass().add("bordered-titled-border"); getChildren().addAll(title, contentPane); } }
@Override public void start(Stage stage) { VBox main = new VBox(); main.setSpacing(50); main.getChildren().add(javafxTextArea); JFXTextArea jfxTextArea = new JFXTextArea(); jfxTextArea.setPromptText("JFoenix Text Area :D"); main.getChildren().add(jfxTextArea); StackPane pane = new StackPane(); pane.getChildren().add(main); StackPane.setMargin(main, new Insets(100)); pane.setStyle("-fx-background-color:WHITE"); final Scene scene = new Scene(pane, 800, 600); scene.getStylesheets() .add(ButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setTitle("JFX Button Demo"); stage.setScene(scene); stage.show();
final Label lbl = new Label("Style Me"); lbl.getStyleClass().add("style1"); // initial style Button btn = new Button("Change the style"); btn.setOnAction(new EventHandler<ActionEvent>() { lbl.getStyleClass().remove("style1"); lbl.getStyleClass().add("style2"); StackPane root = new StackPane(); root.getChildren().add(VBoxBuilder.create().spacing(20).children(lbl, btn).build()); Scene scene = new Scene(root, 300, 250); scene.getStylesheets().add(this.getClass().getResource("style.css").toExternalForm()); primaryStage.setScene(scene); primaryStage.show();
@Override public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Say 'Hello World'"); btn.setOnAction(e -> System.out.println("Hello World!")); VBox box = new VBox(btn); box.getStyleClass().add("box"); StackPane root = new StackPane(); root.setPadding(new Insets(20)); root.getChildren().add(box); Scene scene = new Scene(root, 300, 250); scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm()); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); Region node = (Region) root.lookup(".box"); if (node != null) { Image image = node.getBackground().getImages().get(0).getImage(); System.out.println("Image " + image); } }
BorderPane root = new BorderPane(); Scene scene = new Scene(root,400,400); scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); StackPane sp = new StackPane(); VBox vbox = new VBox(); Button b = new Button("Button"); b.setOnAction(e -> System.out.println("Button clicked")); hbox.getChildren().add(b); vbox.getChildren().add(hbox); sp.getChildren().addAll(pane, vbox); vbox.setPickOnBounds(false); hbox.setPickOnBounds(false); root.setCenter(sp); primaryStage.setScene(scene); primaryStage.show(); } catch(Exception e) { e.printStackTrace();
@Override public void start(Stage primaryStage) { Button btn = new Button("Say 'Hello World'"); btn.setOnAction((ActionEvent event) -> { System.out.println("Hello World!"); }); StackPane root = new StackPane(); root.setId("root"); root.getChildren().add(btn); Scene scene = new Scene(root); scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); }
primaryStage.setTitle("Extension Filter Example"); final Label fileLabel = new Label(); Button btn = new Button("Open FileChooser"); btn.setOnAction(new EventHandler<ActionEvent>() { fileLabel.setText(file.getPath()); VBox vBox = new VBox(30); vBox.getChildren().addAll(fileLabel, btn); vBox.setAlignment(Pos.BASELINE_CENTER); StackPane root = new StackPane(); root.getChildren().add(vBox); primaryStage.setScene(new Scene(root, 300, 250)); primaryStage.show();
Label label = new Label(WORDS); label.setWrapText(true); label.setStyle("-fx-font-family: \"Comic Sans MS\"; -fx-font-size: 20; -fx-text-fill: darkred;"); StackPane layout = new StackPane(); layout.setStyle("-fx-background-color: mistyrose; -fx-padding: 10;"); layout.getChildren().setAll(image, label); stage.setTitle("Love Me Not"); stage.setScene(new Scene(layout)); stage.show();
Label text = new Label("This is a Text"); VBox box = new VBox(); box.setAlignment(Pos.CENTER); text.setStyle("-fx-background-color: yellow;"); box.getChildren().add(text); StackPane container = new StackPane(); container.getChildren().add(box); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show();
imageView.setFitWidth(228); final Label label = new Label("The Once\nand\nFuture King"); label.setStyle("-fx-text-fill: goldenrod; -fx-font: italic 20 \"serif\"; -fx-padding: 0 0 20 0; -fx-text-alignment: center"); StackPane glass = new StackPane(); StackPane.setAlignment(label, Pos.BOTTOM_CENTER); glass.getChildren().addAll(label); glass.setStyle("-fx-background-color: rgba(0, 100, 100, 0.5); -fx-background-radius: 10;"); glass.setMaxWidth(imageView.getFitWidth() - 40); glass.setMaxHeight(imageView.getFitHeight() - 40); final StackPane layout = new StackPane(); layout.getChildren().addAll(imageView, glass); layout.setStyle("-fx-background-color: silver; -fx-padding: 10;"); stage.setScene(new Scene(layout)); stage.show();
Button btn = new Button("Dialog"); List<String> list = Arrays.asList("A", "B", "C", "D"); btn.setOnAction((ActionEvent event) -> { displayDialog(list.iterator()); }); StackPane root = new StackPane(); root.getChildren().add(btn); primaryStage.setScene(scene); primaryStage.show(); Button yes = new Button("Yes"); Button no = new Button("No"); Label text = new Label(iterator.next()); Stage stage = new Stage(); stage.setScene(new Scene(new VBox(text, yes, no))); EventHandler<ActionEvent> handler = evt -> { Labeled source = (Labeled) evt.getSource(); System.out.println("You chose \"" + source.getText() + "\" for \"" + text.getText() + "\""); text.setText(iterator.next()); } else {
Button btn = new Button(); btn.setText("Open second stage"); btn.setOnAction((e) -> { Label l = new Label("I'm a second window"); Scene s = new Scene(l, 100, 100); Stage s1 = new Stage(StageStyle.TRANSPARENT); s1.centerOnScreen(); s1.setScene(s); s1.initModality(Modality.NONE); s1.setAlwaysOnTop(true); s1.setOnShown((e1) -> { }); StackPane root = new StackPane(); root.getChildren().add(btn);
@Override public void start(Stage primaryStage) throws Exception { Pane rootPane = new StackPane(); Scene mainScene = new Scene(rootPane); Button btn = new Button("alert"); rootPane.getChildren().add(btn); blockingRect.widthProperty().bind(primaryStage.widthProperty()); blockingRect.heightProperty().bind(primaryStage.heightProperty()); blockingRect.setFill(Color.LIGHTBLUE); blockingRect.setOpacity(0.5); btn.setOnAction(event -> { rootPane.getChildren().addAll(blockingRect, alertPane); }); }); primaryStage.setFullScreen(true); primaryStage.setScene(mainScene); primaryStage.show();
final Label label = new Label(STANDARD_TEXT); StackPane primaryLayout = new StackPane(); primaryLayout.getChildren().add(label); primaryLayout.setStyle("-fx-background-color: lightgreen; -fx-padding: 10;"); primaryStage.setScene(new Scene(primaryLayout, 200, 100)); primaryStage.setTitle("Primary Stage"); alternateTextCheck.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> selected, Boolean oldValue, Boolean newValue) { if (newValue) label.setText(ALTERNATE_TEXT); else label.setText(STANDARD_TEXT); StackPane secondaryLayout = new StackPane(); secondaryLayout.getChildren().add(alternateTextCheck); secondaryLayout.setStyle("-fx-background-color: cornsilk; -fx-padding: 10;"); secondaryStage.setScene(new Scene(secondaryLayout, 200, 100)); secondaryStage.setTitle("Secondary Stage");
Label lblSecondWindow = new Label("This is the second window"); lblSecondWindow.setAlignment(Pos.TOP_LEFT); lblSecondWindow.autosize(); lblSecondWindow.setVisible(true); StackPane secondLayout = new StackPane(); secondLayout.getChildren().add(lblSecondWindow); Scene secondScene = new Scene(secondLayout, 300, 200); Stage secondStage = new Stage(); secondStage.setTitle("Please Wait"); secondStage.setScene(secondScene); secondStage.show(); try { Thread.sleep(1000); } catch (InterruptedException ex) { } // Stands for expensive operation (the whole try catch) secondStage.close();
StackPane container = new StackPane(list); container.setPadding(new Insets(24)); button.setGraphic(arrow); button.setRipplerFill(Color.WHITE); pane.getTopBar().getChildren().add(button); pane.getBottomBar().getChildren().add(title); title.setStyle("-fx-text-fill:WHITE; -fx-font-size: 40;"); JFXScrollPane.smoothScrolling((ScrollPane) pane.getChildren().get(0)); StackPane.setMargin(title, new Insets(0, 0, 0, 80)); StackPane.setAlignment(title, Pos.CENTER_LEFT); StackPane.setAlignment(button, Pos.CENTER_LEFT); StackPane.setMargin(button, new Insets(0, 0, 0, 20)); final Scene scene = new Scene(new StackPane(pane), 600, 600, Color.WHITE); stage.setTitle("JFX ListView Demo "); stage.setScene(scene); stage.show();