List of usage examples for javafx.scene.layout HBox HBox
public HBox()
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Toggle Button Sample"); stage.setWidth(250);/*from www .ja v a2 s. co m*/ stage.setHeight(180); final ToggleGroup group = new ToggleGroup(); group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { public void changed(ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle) { System.out.println((Color) group.getSelectedToggle().getUserData()); } }); Node rootIcon = new ImageView(new Image(getClass().getResourceAsStream("root.png"))); ToggleButton tb1 = new ToggleButton("A", rootIcon); System.out.println(tb1.toggleGroupProperty()); tb1.setToggleGroup(group); tb1.setUserData(Color.LIGHTGREEN); tb1.setSelected(true); ToggleButton tb2 = new ToggleButton("B"); tb2.setToggleGroup(group); tb2.setUserData(Color.LIGHTBLUE); ToggleButton tb3 = new ToggleButton("C"); tb3.setToggleGroup(group); tb3.setUserData(Color.SALMON); tb3.fire(); HBox hbox = new HBox(); hbox.getChildren().add(tb1); hbox.getChildren().add(tb2); hbox.getChildren().add(tb3); ((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("Toggle Button Sample"); stage.setWidth(250);/* ww w .j ava 2s. com*/ stage.setHeight(180); final ToggleGroup group = new ToggleGroup(); group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { public void changed(ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle) { System.out.println((Color) group.getSelectedToggle().getUserData()); } }); Node rootIcon = new ImageView(new Image(getClass().getResourceAsStream("root.png"))); ToggleButton tb1 = new ToggleButton("A", rootIcon); System.out.println(tb1.toggleGroupProperty()); tb1.setToggleGroup(group); tb1.setUserData(Color.LIGHTGREEN); tb1.setSelected(true); ToggleButton tb2 = new ToggleButton("B"); tb2.setToggleGroup(group); tb2.setUserData(Color.LIGHTBLUE); ToggleButton tb3 = new ToggleButton("C"); tb3.setToggleGroup(group); tb3.setUserData(Color.SALMON); System.out.println(tb3.getToggleGroup()); HBox hbox = new HBox(); hbox.getChildren().add(tb1); hbox.getChildren().add(tb2); hbox.getChildren().add(tb3); ((Group) scene.getRoot()).getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:org.pdfsam.ui.banner.BannerPane.java
@Inject public BannerPane(BannerButtons buttons, ImageView payoff, @Named("logo32") Image logo) { getStyleClass().add("pdfsam-banner"); current.getStyleClass().add("header-title"); HBox.setHgrow(buttons, Priority.ALWAYS); HBox logoView = new HBox(); logoView.getStyleClass().add("pdfsam-logo"); logoView.getChildren().addAll(new ImageView(logo), payoff); getChildren().addAll(logoView, current, buttons); eventStudio().addAnnotatedListeners(this); }
From source file:org.jacp.demo.components.ContactAddDialog.java
private void createAddContactDialog() { final VBox box = new VBox(); box.getStyleClass().add("jacp-option-pane"); box.setMaxSize(300, Region.USE_PREF_SIZE); // the title// ww w . j a v a 2 s . c o m final Label title = new Label("Add new category"); title.setId(GlobalConstants.CSSConstants.ID_JACP_CUSTOM_TITLE); VBox.setMargin(title, new Insets(2, 2, 10, 2)); final HBox hboxInput = new HBox(); final Label nameLabel = new Label("category name:"); HBox.setMargin(nameLabel, new Insets(2)); final TextField nameInput = new TextField(); HBox.setMargin(nameInput, new Insets(0, 0, 0, 5)); HBox.setHgrow(nameInput, Priority.ALWAYS); hboxInput.getChildren().addAll(nameLabel, nameInput); final HBox hboxButtons = new HBox(); hboxButtons.setAlignment(Pos.CENTER_RIGHT); final Button ok = new Button("OK"); HBox.setMargin(ok, new Insets(6, 5, 4, 2)); final Button cancel = new Button("Cancel"); HBox.setMargin(cancel, new Insets(6, 2, 4, 5)); cancel.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent arg0) { JACPModalDialog.getInstance().hideModalDialog(); } }); ok.setDefaultButton(true); ok.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent actionEvent) { final String catName = nameInput.getText(); if (catName != null && StringUtils.hasText(catName)) { // contacts final Contact contact = new Contact(); contact.setFirstName(catName); parent.getContext().send(contact); JACPModalDialog.getInstance().hideModalDialog(); } } }); hboxButtons.getChildren().addAll(ok, cancel); box.getChildren().addAll(title, hboxInput, hboxButtons); JACPModalDialog.getInstance().showModalDialog(box); }
From source file:org.samcrow.frameviewer.ui.db.DatabaseConnectionDialog.java
public DatabaseConnectionDialog(String connectionTypeName) { this.connectionTypeName = connectionTypeName; setTitle("Database connection"); // Placeholder root.getChildren().add(new Region()); // Buttons// w w w.ja v a 2s.com { final HBox buttonBox = new HBox(); buttonBox.setPadding(new Insets(10)); cancelButton.setCancelButton(true); buttonBox.getChildren().add(cancelButton); cancelButton.setOnAction((ActionEvent t) -> { hide(); }); final Region spacer = new Region(); buttonBox.getChildren().add(spacer); HBox.setHgrow(spacer, Priority.ALWAYS); nextButton.setDefaultButton(true); buttonBox.getChildren().add(nextButton); root.getChildren().add(buttonBox); } switchToConnection(); final Scene scene = new Scene(root, 220, root.getPrefHeight()); setScene(scene); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 260, 80); stage.setScene(scene);/*from w w w .j a v a 2 s.com*/ stage.setTitle("Password Field Sample"); VBox vb = new VBox(); vb.setPadding(new Insets(10, 0, 0, 10)); vb.setSpacing(10); HBox hb = new HBox(); hb.setSpacing(10); hb.setAlignment(Pos.CENTER_LEFT); Label label = new Label("Password"); final PasswordField pb = new PasswordField(); pb.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (!pb.getText().equals("abc")) { message.setText("Your password is incorrect!"); message.setTextFill(Color.web("red")); } else { message.setText("Your password has been confirmed"); message.setTextFill(Color.web("black")); } pb.setText(""); } }); hb.getChildren().addAll(label, pb); vb.getChildren().addAll(hb, message); scene.setRoot(vb); stage.show(); }
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);//from w w w.j a v a 2s. co 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); }
From source file:com.bdb.weather.display.current.Thermometer.java
/** * Constructor./*from w w w .j a v a 2s. c o m*/ * * @param title The title to display in the containing panel * @param min The minimum value for the thermometer scale * @param max The maximum value for the thermometer scale */ public Thermometer(String title, Temperature min, Temperature max) { this.setPrefSize(150.0, 200.0); minValue = min; maxValue = max; unitProperty.setValue(Temperature.getDefaultUnit()); setUnits(unitProperty.getValue()); ChartViewer chartViewer = createChartElements(); this.setCenter(chartViewer); HBox p = new HBox(); p.setAlignment(Pos.CENTER); Label label = new Label("High: "); label.setStyle("-fx-font-weight: bold"); p.getChildren().addAll(label, highLabel); this.setTop(p); p = new HBox(); p.setAlignment(Pos.CENTER); label = new Label("Low: "); label.setStyle("-fx-font-weight: bold"); p.getChildren().addAll(label, lowLabel); this.setBottom(p); unitProperty.addListener((ObservableValue<? extends Temperature.Unit> observable, Temperature.Unit oldValue, Temperature.Unit newValue) -> { setUnits(newValue); }); }
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);/*from www .j av a 2s .com*/ 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:org.pdfsam.ui.news.NewsStage.java
@Inject public NewsStage(Collection<Image> logos, StylesConfig styles, @Named("newsDisplayPolicy") PreferenceComboBox<KeyStringValueItem<String>> newsDisplayPolicy) { BorderPane containerPane = new BorderPane(); browser.setId("newsBrowser"); containerPane.getStyleClass().addAll(Style.CONTAINER.css()); containerPane.getStyleClass().add("-pdfsam-news-pane"); containerPane.setCenter(browser);// w w w.j a va 2 s. c o m HBox bottom = new HBox(); ClosePane closePane = new ClosePane(); HBox.setHgrow(closePane, Priority.ALWAYS); HBox comboPanel = new HBox(new Label(DefaultI18nContext.getInstance().i18n("Show this:")), newsDisplayPolicy); comboPanel.getStyleClass().addAll(Style.CONTAINER.css()); comboPanel.getStyleClass().add("-pdfsam-news-pane-bottom"); bottom.getChildren().addAll(comboPanel, closePane); containerPane.setBottom(bottom); Scene scene = new Scene(containerPane); scene.getStylesheets().addAll(styles.styles()); scene.setOnKeyReleased(new HideOnEscapeHandler(this)); setScene(scene); setTitle(DefaultI18nContext.getInstance().i18n("What's new")); getIcons().addAll(logos); setMaximized(false); }