List of usage examples for javafx.scene.layout HBox setSpacing
public final void setSpacing(double value)
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);//w ww .ja v a2 s . c om stage.setHeight(180); HBox hbox = new HBox(); Image image = new Image(getClass().getResourceAsStream("labels.jpg")); Label label1 = new Label("Search", new ImageView(image)); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); label1.setLabelFor(hbox); System.out.println(label1.getLabelFor()); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Label Sample"); stage.setWidth(400);/*from w ww. j a v a2 s .c o m*/ stage.setHeight(180); HBox hbox = new HBox(); Image image = new Image(getClass().getResourceAsStream("labels.jpg")); Label label1 = new Label("Search", new ImageView(image)); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); label1.setLabelFor(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("Label Sample"); stage.setWidth(400);//from ww w.j a va 2 s. c om stage.setHeight(180); HBox hbox = new HBox(); Label label1 = new Label("Search long long long long long long long long long "); label1.setPrefWidth(100); label1.setWrapText(true); 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.setTitle("Label Sample"); stage.setWidth(400);/*from ww w .j av a 2s .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 w w . java2 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:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Radio Button Sample"); stage.setWidth(250);//from www .java 2 s. com 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: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 v a 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:Main.java
private AnchorPane addAnchorPane(GridPane grid) { AnchorPane anchorpane = new AnchorPane(); Button buttonSave = new Button("Save"); Button buttonCancel = new Button("Cancel"); HBox hb = new HBox(); hb.setPadding(new Insets(0, 10, 10, 10)); hb.setSpacing(10); hb.getChildren().addAll(buttonSave, buttonCancel); anchorpane.getChildren().addAll(grid, hb); // Anchor buttons to bottom right, anchor grid to top AnchorPane.setBottomAnchor(hb, 8.0); AnchorPane.setRightAnchor(hb, 5.0);/*from ww w . j a v a 2 s .c o m*/ AnchorPane.setTopAnchor(grid, 10.0); return anchorpane; }
From source file:Main.java
private HBox addHBox() { HBox hbox = new HBox(); hbox.setPadding(new Insets(15, 12, 15, 12)); hbox.setSpacing(10); // Gap between nodes hbox.setStyle("-fx-background-color: #336699;"); Button buttonCurrent = new Button("Current"); buttonCurrent.setPrefSize(100, 20);//w ww. j a v a 2 s .c o m Button buttonProjected = new Button("Projected"); buttonProjected.setPrefSize(100, 20); hbox.getChildren().addAll(buttonCurrent, buttonProjected); return hbox; }
From source file:guipart.AddMessageUploadFile.java
private void setScene(Stage window) { fileNames = new ArrayList<File>(); fileList = new ListView<String>(); files = FXCollections.observableArrayList(); fileList.setItems(files);// w ww . java 2 s . c o m fileList.setTranslateY(-50); fileList.setMaxWidth(300); fileList.setMinHeight(150); Label addMessagesLabel = new Label("Add messages"); Label loadedMessagesLabel = new Label("Loaded messages:"); Label imageLabel2 = new Label(); Image image2 = new Image(getClass().getResourceAsStream("/resources/gui/labelme_logo.png")); imageLabel2.setGraphic(new ImageView(image2)); imageLabel2.setPrefSize(200, 200); HBox imageBox2 = new HBox(); imageBox2.setAlignment(Pos.CENTER); imageBox2.setPadding(new Insets(20, 20, 20, 20)); imageBox2.getChildren().add(imageLabel2); acceptButton = new Button("Accept All"); browseButton = new Button("Browse"); finishButton = new Button("Finish"); previousButton = new Button("Previous"); cancelButton = new Button("X"); backButton = new Button("Back"); pathField.setMinWidth(200); textCategory = new Label(); addMessagesLabel.setFont(Font.font("Arial", FontWeight.BOLD, 28)); HBox hBox = new HBox(); hBox.setSpacing(20); hBox.getChildren().addAll(browseButton, pathField, acceptButton); hBox.setAlignment(Pos.CENTER); VBox layout = new VBox(); layout.setSpacing(30); VBox filesPlaceholder = new VBox(); filesPlaceholder.setSpacing(10); backButton.setTranslateY(-50); browseButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { //TODO: add more extensionFilters File currDir = new File("."); fileChooser.setInitialDirectory(currDir); fileChooser.getExtensionFilters().addAll((new FileChooser.ExtensionFilter("Text Files", "*.txt"))); File file = fileChooser.showOpenDialog(window); if (file != null) { pathField.setText(file.getName()); fileNames.add(file); files.add(file.getName()); } } }); fileList.setOnMouseClicked(e -> { //System.out.println(fileList.getSelectionModel().getSelectedItem()); files.remove(fileList.getSelectionModel().getSelectedItem()); for (File file : fileNames) { if (file.getName().equals(fileList.getSelectionModel().getSelectedItem())) { fileNames.remove(file); break; } } }); acceptButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!fileNames.isEmpty()) { Categorize categorize = new Categorize(); categorize.trainModel(); int size = files.size(); for (int i = 0; i < size; i++) { String fileName = files.get(i); for (File file : fileNames) { if (file.getName().equals(fileName)) { try { files.add(fileName + " " + categorize.getCategory(FileUtils.readFileToString(file, "UTF-8"))); } catch (IOException ex) { Logger.getLogger(AddMessageUploadFile.class.getName()).log(Level.SEVERE, null, ex); } } } } int i = 0; while (i < size) { files.remove(0); i++; } /* try { textCategory.setText("The text category is: " + categorize.getCategory(FileUtils.readFileToString(fileNames.get(fileNames.size() - 1), "UTF-8"))); } catch (IOException ex) { Logger.getLogger(AddMessageUploadFile.class.getName()).log(Level.SEVERE, null, ex); }*/ } /* if (pathField.getText() != null) { int index = pathField.getText().lastIndexOf("\\"); Label messageLabel = new Label(pathField.getText().substring(index + 1)); messageLabel.setMinWidth(200); messageLabel.setMinHeight(25); messageLabel.setStyle("-fx-fill: orange;\n" + "-fx-border-color: blue;\n" + "-fx-border-width: 3;\n"); if (filesPlaceholder.getChildren().size() != 0) { layout.getChildren().remove(layout.getChildren().size() - 1); } filesPlaceholder.getChildren().addAll(messageLabel); filesPlaceholder.setAlignment(Pos.CENTER); filesPlaceholder.setPadding(new Insets(0, 0, 0, 50)); layout.getChildren().add(filesPlaceholder); }*/ } }); backButton.setOnAction(e -> { window.setScene(mainPage.mainPageScene); }); layout.getChildren().addAll(imageLabel2, addMessagesLabel, hBox, textCategory, fileList, backButton); layout.setStyle("-fx-background-color: white"); layout.setAlignment(Pos.TOP_CENTER); layout.setStyle("-fx-background-color: #B8EDFF;"); scene = new Scene(layout, 900, 600); }