List of usage examples for javafx.scene.layout HBox getChildren
@Override
public ObservableList<Node> getChildren()
From source file:kz.aksay.polygraph.desktop.LoginPane.java
public LoginPane() { GridPane grid = this; grid.setAlignment(Pos.CENTER);//from ww w .jav a 2 s . co m grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); sceneTitle = new Text(" "); sceneTitle.setId("welcome-text"); grid.add(sceneTitle, 0, 0, 2, 1); userName = new Label(":"); grid.add(userName, 0, 1); userTextField = new TextField(); grid.add(userTextField, 1, 1); password = new Label(":"); grid.add(password, 0, 2); passwordTextBox = new PasswordField(); grid.add(passwordTextBox, 1, 2); signIn = new Button(""); HBox hbBtn = new HBox(10); hbBtn.setAlignment(Pos.BOTTOM_RIGHT); hbBtn.getChildren().add(signIn); grid.add(hbBtn, 1, 4); final Text actionTarget = new Text(); actionTarget.setId("action-target"); actionTarget.setWrappingWidth(300); grid.add(actionTarget, 0, 6, 2, 1); signIn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (isSignInSuccess()) { onSignInSuccess.handle(e); } else { actionTarget.setText( "? . !"); } } }); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);// www . j a va 2 s . co m stage.setHeight(180); HBox hbox = new HBox(); Image image = new Image(getClass().getResourceAsStream("labels.jpg")); Label label1 = new Label("Search"); label1.setGraphic(new ImageView(image)); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setWidth(250);//from w ww .j ava 2s.c om stage.setHeight(150); final ToggleGroup group = new ToggleGroup(); RadioButton rb1 = new RadioButton("A"); rb1.setToggleGroup(group); rb1.setUserData("A"); RadioButton rb2 = new RadioButton("B"); rb2.setToggleGroup(group); rb2.setUserData("B"); RadioButton rb3 = new RadioButton("C"); rb3.setToggleGroup(group); rb3.setUserData("C"); group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) { if (group.getSelectedToggle() != null) { System.out.println(group.getSelectedToggle().getUserData().toString()); } } }); HBox hbox = new HBox(); VBox vbox = new VBox(); vbox.getChildren().add(rb1); vbox.getChildren().add(rb2); vbox.getChildren().add(rb3); vbox.setSpacing(10); hbox.getChildren().add(vbox); hbox.setSpacing(50); hbox.setPadding(new Insets(20, 10, 10, 20)); ((Group) scene.getRoot()).getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Radio Button Sample"); stage.setWidth(250);/*from w w w . ja v a 2 s .c o m*/ stage.setHeight(150); final ToggleGroup group = new ToggleGroup(); RadioButton rb1 = new RadioButton("A"); rb1.setToggleGroup(group); rb1.setUserData("A"); RadioButton rb2 = new RadioButton("B"); rb2.setToggleGroup(group); rb2.setUserData("B"); RadioButton rb3 = new RadioButton("C"); rb3.setToggleGroup(group); rb3.setUserData("C"); group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) { if (group.getSelectedToggle() != null) { System.out.println(group.getSelectedToggle().getUserData().toString()); } } }); HBox hbox = new HBox(); VBox vbox = new VBox(); vbox.getChildren().add(rb1); vbox.getChildren().add(rb2); vbox.getChildren().add(rb3); vbox.setSpacing(10); hbox.getChildren().add(vbox); hbox.setSpacing(50); hbox.setPadding(new Insets(20, 10, 10, 20)); ((Group) scene.getRoot()).getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:User.java
private HBox drawRow2() { PasswordField passwordField = new PasswordField(); passwordField.setFont(Font.font("SanSerif", 20)); passwordField.setPromptText("Password"); passwordField.setStyle(/*from ww w . j ava 2 s. co m*/ "-fx-text-fill:black; " + "-fx-prompt-text-fill:gray; " + "-fx-highlight-text-fill:black; " + "-fx-highlight-fill: gray; " + "-fx-background-color: rgba(255, 255, 255, .80); "); passwordField.prefWidthProperty().bind(primaryStage.widthProperty().subtract(55)); user.passwordProperty().bind(passwordField.textProperty()); // error icon SVGPath deniedIcon = new SVGPath(); deniedIcon.setFill(Color.rgb(255, 0, 0, .9)); deniedIcon.setStroke(Color.WHITE);// deniedIcon.setContent("M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 " + "16.447,13.08710.945,7.585 8.117,10.415 13.618,15.917 8.116,21.419 10" + ".946,24.248 16.447,18.746 21.948,24.248z"); deniedIcon.setVisible(false); SVGPath grantedIcon = new SVGPath(); grantedIcon.setFill(Color.rgb(0, 255, 0, .9)); grantedIcon.setStroke(Color.WHITE);// grantedIcon.setContent( "M2.379,14.729 5.208,11.899 12.958,19.648 25.877," + "6.733 28.707,9.56112.958,25.308z"); grantedIcon.setVisible(false); // StackPane accessIndicator = new StackPane(); accessIndicator.getChildren().addAll(deniedIcon, grantedIcon); accessIndicator.setAlignment(Pos.CENTER_RIGHT); grantedIcon.visibleProperty().bind(GRANTED_ACCESS); // user hits the enter key passwordField.setOnAction(actionEvent -> { if (GRANTED_ACCESS.get()) { System.out.printf("User %s is granted access.\n", user.getUserName()); System.out.printf("User %s entered the password: %s\n", user.getUserName(), user.getPassword()); Platform.exit(); } else { deniedIcon.setVisible(true); } ATTEMPTS.set(ATTEMPTS.add(1).get()); System.out.println("Attempts: " + ATTEMPTS.get()); }); // listener when the user types into the password field passwordField.textProperty().addListener((obs, ov, nv) -> { boolean granted = passwordField.getText().equals(MY_PASS); GRANTED_ACCESS.set(granted); if (granted) { deniedIcon.setVisible(false); } }); // listener on number of attempts ATTEMPTS.addListener((obs, ov, nv) -> { if (MAX_ATTEMPTS == nv.intValue()) { // failed attempts System.out.printf("User %s is denied access.\n", user.getUserName()); Platform.exit(); } }); // second row HBox row2 = new HBox(3); row2.getChildren().addAll(passwordField, accessIndicator); return row2; }
From source file:at.ac.tuwien.qse.sepm.gui.control.ImageTile.java
public ImageTile() { getStyleClass().add("imageTile"); Group overlay = new Group(); HBox overlayBox = new HBox(); overlayBox.getStyleClass().add("hoverlay"); overlayBox.getChildren().addAll(overLayIcon, name); overlay.getChildren().add(overlayBox); StackPane.setAlignment(overlay, Pos.CENTER); placeHolder.setGlyphSize(ImageSize.LARGE.pixels() * 0.6); setMinHeight(0);/* w w w . jav a2 s. c om*/ setMinWidth(0); imageView.setPreserveRatio(false); getChildren().add(placeHolder); getChildren().add(imageView); getChildren().add(overlay); setAlignment(overlay, Pos.CENTER); setOnMouseEntered((event) -> { if (photos.size() > 0) { setCursor(Cursor.HAND); } }); setOnMouseExited((event -> setCursor(Cursor.DEFAULT))); imageView.visibleProperty().bind(photosProperty.emptyProperty().not()); overlay.visibleProperty().bind(photosProperty.emptyProperty().not().and(name.textProperty().isNotEmpty())); placeHolder.visibleProperty().bind(photosProperty.emptyProperty()); heightProperty().addListener(this::handleSizeChange); widthProperty().addListener(this::handleSizeChange); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Split Views"); Group root = new Group(); Scene scene = new Scene(root, 350, 250, Color.WHITE); SplitPane splitPane = new SplitPane(); splitPane.prefWidthProperty().bind(scene.widthProperty()); splitPane.prefHeightProperty().bind(scene.heightProperty()); VBox leftArea = new VBox(10); HBox rowBox = new HBox(20); final Text leftText = TextBuilder.create().text("Left ").translateX(20).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 20)).build(); rowBox.getChildren().add(leftText); leftArea.getChildren().add(rowBox);/*from w w w .j av a 2s. c om*/ leftArea.setAlignment(Pos.CENTER); SplitPane splitPane2 = new SplitPane(); splitPane2.setOrientation(Orientation.VERTICAL); splitPane2.prefWidthProperty().bind(scene.widthProperty()); splitPane2.prefHeightProperty().bind(scene.heightProperty()); HBox centerArea = new HBox(); final Text upperRight = TextBuilder.create().text("Text").x(100).y(50).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 35)).translateY(50).build(); centerArea.getChildren().add(upperRight); HBox rightArea = new HBox(); final Text lowerRight = TextBuilder.create().text("Lower Right").x(100).y(50).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 35)).translateY(50).build(); rightArea.getChildren().add(lowerRight); splitPane2.getItems().add(centerArea); splitPane2.getItems().add(rightArea); splitPane.getItems().add(leftArea); splitPane.getItems().add(splitPane2); ObservableList<SplitPane.Divider> dividers = splitPane.getDividers(); for (int i = 0; i < dividers.size(); i++) { dividers.get(i).setPosition((i + 1.0) / 3); } HBox hbox = new HBox(); hbox.getChildren().add(splitPane); root.getChildren().add(hbox); primaryStage.setScene(scene); primaryStage.show(); }
From source file:ijfx.ui.canvas.FxCanvasTester.java
@Override public void start(Stage primaryStage) { final SCIFIO scifio = new SCIFIO(); MenuBar menuBar = new MenuBar(); InputControl parameterInput = null;/*from w ww .j a va 2s . c o m*/ try { System.setProperty("imagej.legacy.sync", "true"); //reader.getContext().inject(this); ImageJ imagej = new ImageJ(); context = imagej.getContext(); CommandInfo command = imagej.command().getCommand(GaussianBlur.class); CommandModuleItem input = command.getInput("sigma"); Class<?> type = input.getType(); if (type == double.class) { type = Double.class; } context.inject(this); GaussianBlur module = new GaussianBlur(); imagej.ui().showUI(); //reader = scifio.initializer().initializeReader("./stack.tif"); commandService.run(OpenFile.class, true, new HashMap<String, Object>()); menuBar = new MenuBar(); menuService.createMenus(new FxMenuCreator(), menuBar); ObjectMapper mapper = new ObjectMapper(); SimpleModule simpleModule = new SimpleModule("ModuleSerializer"); // simpleModule.addSerializer(ModuleItem<?>.class,new ModuleItemSerializer()); simpleModule.addSerializer(ModuleInfo.class, new ModuleSerializer()); simpleModule.addSerializer(ModuleItem.class, new ModuleItemSerializer()); mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.registerModule(simpleModule); mapper.writeValue(new File("modules.json"), moduleService.getModules()); } catch (Exception ex) { ImageJFX.getLogger(); } //imageView.fitImageToScreen(); Button reset = new Button("Reset"); reset.setOnAction(event -> update()); BorderPane pane = new BorderPane(); Button test = new Button("Test"); AnchorPane root = new AnchorPane(); root.getChildren().add(pane); root.getStylesheets().add(ArcMenu.class.getResource("arc-default.css").toExternalForm()); root.getStylesheets().add(ImageJFX.class.getResource(("flatterfx.css")).toExternalForm()); AnchorPane.setTopAnchor(pane, 0.0); AnchorPane.setBottomAnchor(pane, 0.0); AnchorPane.setLeftAnchor(pane, 0.0); AnchorPane.setRightAnchor(pane, 0.0); pane.setTop(menuBar); HBox vbox = new HBox(); vbox.getChildren().addAll(reset, test, parameterInput); vbox.setSpacing(10); vbox.setPadding(new Insets(10, 10, 10, 10)); // update(); pane.setCenter(ImageWindowContainer.getInstance()); // pane.setPrefSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE); pane.setBottom(vbox); Scene scene = new Scene(root, 600, 600); test.setOnAction(event -> { test(); }); primaryStage.setTitle("ImageCanvasTest"); primaryStage.setScene(scene); primaryStage.show(); }
From source file:User.java
private HBox drawRow1() { Text userNameField = new Text(); userNameField.setFont(Font.font("SanSerif", FontWeight.BOLD, 30)); userNameField.setFill(foregroundColor); userNameField.setSmooth(true);/* www . j a va 2 s. co m*/ // bind the field to the user.username userNameField.textProperty().bind(user.userNameProperty()); HBox userNameCell = new HBox(); userNameCell.prefWidthProperty().bind(primaryStage.widthProperty().subtract(45)); userNameCell.getChildren().add(userNameField); HBox row1 = new HBox(); row1.getChildren().addAll(userNameCell); return row1; }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 300, 250, Color.WHITE); HBox hbox = new HBox(); Button button1 = new Button("Add"); Button button2 = new Button("Remove"); HBox.setHgrow(button1, Priority.ALWAYS); HBox.setHgrow(button2, Priority.ALWAYS); button1.setMaxWidth(Double.MAX_VALUE); button2.setMaxWidth(Double.MAX_VALUE); hbox.getChildren().addAll(button1, button2); hbox.setPrefWidth(400);//from ww w .ja v a 2 s. c om System.out.println(HBox.getMargin(button1)); root.getChildren().add(hbox); primaryStage.setScene(scene); primaryStage.show(); }