HBox hbox = new HBox(); Label label = new Label("(empty)"); Pane pane = new Pane(); Button button = new Button("(>)"); String lastItem; hbox.getChildren().addAll(label, pane, button); HBox.setHgrow(pane, Priority.ALWAYS); button.setOnAction(new EventHandler<ActionEvent>() { StackPane pane = new StackPane(); Scene scene = new Scene(pane, 300, 150); primaryStage.setScene(scene); ObservableList<String> list = FXCollections.observableArrayList( "Item 1", "Item 2", "Item 3", "Item 4"); primaryStage.show();
setText(null); if (hbox == null) { hbox = new HBox(3); hbox.getChildren().setAll(treeItem.getGraphic(), (Node) item); setGraphic(hbox); } else {
HBox hbox = new HBox(); Label label = new Label("file"); ImageView imageView = new ImageView("path to image"); hbox.getChildren().add(label); hbox.getChildren().add(imageView); TreeItem itm = new TreeItem(hbox); rootItem.getChildren().add(itm);
//For example, if an hbox needs the TextField to be allocated all extra space: HBox hbox = new HBox(); TextField field = new TextField(); HBox.setHgrow(field, Priority.ALWAYS); hbox.getChildren().addAll(new Label("Search:"), field, new Button("Go"));
vb.setPadding( new Inset(10,10,10,10) ); vb.setSpacing( 10 ); Button yesButton = new Button( "Yes" ); yesButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle( ActionEvent e ) { Button noButton = new Button( "No" ); noButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle( ActionEvent e ) { HBox buttons = new HBox(); buttons.setAlignment( Pos.CENTER ); buttons.setSpacing( 10 ); buttons.getChildren().addAll( yesButton, noButton ); bp.setCenter( buttons ); HBox msg = new HBox(); msg.setSpacing( 5 ); msg.getChildren().addAll( icon, new Message( message ) ); BorderPane bp = new BorderPane(); bp.setCenter( okButton ); HBox msg = new HBox(); msg.setSpacing( 5 ); msg.getChildren().addAll( icon, message );
); final Label currentRaceStage = new Label(); currentRaceStage.textProperty().bind( taskMonitor.currentTaskNameProperty() final Button startButton = new Button("Start Race"); startButton.disableProperty().bind(taskMonitor.idleProperty().not()); startButton.setOnAction(new EventHandler<ActionEvent>() { final HBox raceProgress = new HBox(10); raceProgress.getChildren().setAll( currentRaceStage,
public class cursor extends Application { @Override public void start(Stage primaryStage) { HBox root = new HBox(); Scene scene = new Scene(root); scene.setCursor(Cursor.NONE); primaryStage.setScene(scene); primaryStage.setWidth(300); primaryStage.setHeight(300); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
Hbox layout =new HBox(10); ColorPicker colorPicker = new ColorPicker(); colorPicker.setValue(Color.RED);//Red is the default shown at first Label label =new Label("Your Text"); layout.getChildren().addAll(label,colorPicker); //Then colorPicker.setOnAction(event->{ label.setFill(colorPicker.getValue()); });
new Label("500: Aug 8, 12:15pm"), new Label("404: Aug 7, 3:27am") ).build(); Label nErrors = new Label(); nErrors.getStyleClass().add("nerrors"); nErrors.textProperty().bind(Bindings.size(errorPane.getChildren()).asString()); ); HBox layout = new HBox(10); layout.setStyle("-fx-padding: 10; -fx-background-color: cornsilk;"); layout.getChildren().addAll(adminPane, viewPane, connectivityPane); layout.setPrefHeight(150); layout.getStylesheets().add(this.getClass().getResource("titledpanecustomization.css").toExternalForm()); primaryStage.setScene(new Scene(layout)); primaryStage.show();
HBox hbox = new HBox(); // the text of the "button" Label lbl_txt = new Label("Text"); // the icon of the "button", i am using Labels for icon(with css) Label lbl_ico = new Label("ico"); hbox.getChildren().addAll(lbl_txt, lbl_ico); hbox.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { // alternative to Button click } });
HBox hbox = new HBox(); TextField field = new TextField(); HBox.setHgrow(field, Priority.ALWAYS); hbox.getChildren().addAll(new Label("Search:"), field, new Button("Go"));
HBox box = new HBox(); Button confirm = new Button(); box.getChildren().add(confirm); borderPane.setBottom(box);
@Override public void start(Stage stage) { HBox pane = new HBox(clock1, clock2); pane.setSpacing(20); Scene scene = new Scene(pane); stage.setTitle("Medusa Clock Control"); stage.setScene(scene); stage.show(); // Calculate number of nodes calcNoOfNodes(pane); System.out.println(noOfNodes + " Nodes in SceneGraph"); }
selectedYearLabel.setFont(Font.font(ROBOTO, FontWeight.BOLD, 14)); HBox yearLabelContainer = new HBox(); yearLabelContainer.getStyleClass().add("spinner"); yearLabelContainer.getChildren().addAll(selectedYearLabel); yearLabelContainer.setAlignment(Pos.CENTER_LEFT); yearLabelContainer.setFillHeight(false); selectedDateLabel.setFont(Font.font(ROBOTO, FontWeight.BOLD, 32)); HBox selectedDateContainer = new HBox(selectedDateLabel); selectedDateContainer.getStyleClass().add("spinner"); selectedDateContainer.setAlignment(Pos.CENTER_LEFT);
@Override public void start(Stage myStage) { HBox hBox1 = new HBox(); hBox1.setAlignment(Pos.CENTER); getRandomHieroglyphic(hBox1); Button refresh = new Button("Refresh"); refresh.setOnAction(e -> getRandomHieroglyphic(hBox1)); BorderPane borderPane = new BorderPane(); borderPane.getBottom().add(refresh); myStage.setTitle("Random Hieroglyphics with Refresh"); Scene myScene = new Scene(borderPane, 400, 400);
@Override public void start(Stage primaryStage) throws Exception { JFXComboBox<Label> combo = new JFXComboBox<>(); combo.getItems().add(new Label("Java 1.8")); combo.getItems().add(new Label("Java 1.7")); combo.getItems().add(new Label("Java 1.6")); combo.getItems().add(new Label("Java 1.5")); combo.setEditable(true); combo.setPromptText("Select Java Version"); combo.setConverter(new StringConverter<Label>() { @Override public String toString(Label object) { return object==null? "" : object.getText(); } @Override public Label fromString(String string) { return new Label(string); } }); HBox pane = new HBox(100); HBox.setMargin(combo, new Insets(20)); pane.setStyle("-fx-background-color:WHITE"); pane.getChildren().add(combo); final Scene scene = new Scene(pane, 300, 300); scene.getStylesheets().add(ComboBoxDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); primaryStage.setTitle("JFX ComboBox Demo"); primaryStage.setScene(scene); primaryStage.setResizable(false); primaryStage.show(); }
HBox box = new HBox(); CheckBox cb = new CheckBox(); Label text = new Label("Show on Startup"); box.getChildren().addAll(text, cb); box.setSpacing(5);