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 . java 2s. c om stage.setHeight(180); HBox hbox = new HBox(); final Label label1 = new Label("Search long long long long long long long long long "); label1.setOnMouseEntered(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { label1.setScaleX(1.5); label1.setScaleY(1.5); } }); label1.setOnMouseExited(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { label1.setScaleX(1); label1.setScaleY(1); } }); hbox.setSpacing(10); hbox.getChildren().add((label1)); ((Group) scene.getRoot()).getChildren().add(hbox); stage.setScene(scene); stage.show(); }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
public void addChartScore() { colScore.setCellFactory(new Callback<TableColumn<ReportRow, String>, TableCell<ReportRow, String>>() { @Override// www .j a va2 s . com public TableCell<ReportRow, String> call(TableColumn<ReportRow, String> param) { TableCell<ReportRow, String> cell = new TableCell<ReportRow, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!empty && item != null) { Double score = item.indexOf("%") < 0 || item.indexOf("?") >= 0 ? 0 : Double.parseDouble(item.substring(0, item.indexOf('%'))); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Correct", score), new PieChart.Data("Error", 100 - score)); PieChart chart = new PieChart(pieChartData); chart.setId("pie_chart"); chart.setMinSize(22, 22); chart.setMaxSize(22, 22); HBox box = new HBox(); box.setSpacing(8); box.setAlignment(Pos.CENTER_LEFT); Label score_label = new Label(item); score_label.setTextFill(Color.LIGHTGRAY); box.getChildren().add(chart); box.getChildren().add(score_label); setGraphic(box); } else { setGraphic(null); } } }; return cell; } }); }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
public void addDeleteIcon() { colDelete.setCellFactory(new Callback<TableColumn<ReportRow, String>, TableCell<ReportRow, String>>() { @Override/*from ww w . j a v a 2 s . c om*/ public TableCell<ReportRow, String> call(TableColumn<ReportRow, String> param) { TableCell<ReportRow, String> cell = new TableCell<ReportRow, String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (!empty && item != null) { String path = getModel().getItemById(item).getDeletePath(); HBox box = new HBox(); box.setSpacing(3); box.setAlignment(Pos.CENTER_LEFT); Button icon = new Button(); icon.setMinHeight(20); icon.setPrefHeight(20); icon.setMaxHeight(20); icon.setMinWidth(20); icon.setPrefWidth(20); icon.setMaxWidth(20); icon.getStyleClass().addAll("delete-img", "periodic-img"); icon.setCursor(Cursor.HAND); icon.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { // Delete report File file = new File(path); File dir = new File(file.getParent()); try { FileUtils.deleteDirectory(dir); } catch (IOException e) { e.printStackTrace(); } getModel().removeItem(item); addData(); } }); box.getChildren().add(icon); setGraphic(box); } } }; return cell; } }); }
From source file:boundary.GraphPane.java
private HBox addTransformingModeOptions() { HBox hBox = new HBox(); hBox.setPadding(new Insets(15, 12, 15, 12)); hBox.setSpacing(10); hBox.setStyle("-fx-background-color: #66FFFF;"); final ToggleGroup optionGroup = new ToggleGroup(); Label lblMouseMode = new Label("Mouse Mode: "); lblMouseMode.setPrefSize(100, 20);//from www . j av a2s. co m RadioButton rbTransform = new RadioButton("Pan & Zoom"); rbTransform.setPrefSize(100, 20); rbTransform.setToggleGroup(optionGroup); rbTransform.setUserData("T"); rbTransform.setSelected(true); RadioButton rbPick = new RadioButton("Picking"); rbPick.setPrefSize(100, 20); rbPick.setUserData("P"); rbPick.setToggleGroup(optionGroup); optionGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { if (optionGroup.getSelectedToggle() != null) { DefaultModalGraphMouse dmg = (DefaultModalGraphMouse) vv.getGraphMouse(); if (optionGroup.getSelectedToggle().getUserData().equals("T")) { dmg.setMode(Mode.TRANSFORMING); } else if (optionGroup.getSelectedToggle().getUserData().equals("P")) { dmg.setMode(Mode.PICKING); } } } }); hBox.getChildren().addAll(lblMouseMode, rbTransform, rbPick); return hBox; }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java
public void addFormatIcons() { colFormats.setCellFactory(//from www .j a v a 2 s . co m new Callback<TableColumn<ReportRow, ObservableMap<String, String>>, TableCell<ReportRow, ObservableMap<String, String>>>() { @Override public TableCell<ReportRow, ObservableMap<String, String>> call( TableColumn<ReportRow, ObservableMap<String, String>> param) { TableCell<ReportRow, ObservableMap<String, String>> cell = new TableCell<ReportRow, ObservableMap<String, String>>() { @Override public void updateItem(ObservableMap<String, String> item, boolean empty) { super.updateItem(item, empty); if (!empty && item != null) { HBox box = new HBox(); box.setSpacing(3); box.setAlignment(Pos.CENTER_LEFT); for (String i : item.keySet()) { ImageView icon = new ImageView(); icon.setId("but" + i); icon.setFitHeight(20); icon.setFitWidth(20); icon.setImage(new Image("images/formats/" + i + ".png")); icon.setCursor(Cursor.HAND); String type = i; String path = item.get(i); icon.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { ArrayMessage am = new ArrayMessage(); am.add(GuiConfig.PERSPECTIVE_SHOW, new UiMessage()); am.add(GuiConfig.PERSPECTIVE_SHOW + "." + GuiConfig.COMPONENT_SHOW, new ShowMessage(type, path)); getContext().send(GuiConfig.PERSPECTIVE_SHOW, am); } }); ContextMenu contextMenu = new ContextMenu(); javafx.scene.control.MenuItem download = new javafx.scene.control.MenuItem( "Download report"); contextMenu.getItems().add(download); icon.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() { public void handle(ContextMenuEvent e) { contextMenu.show(icon, e.getScreenX(), e.getScreenY()); } }); box.getChildren().add(icon); } setGraphic(box); } else { setGraphic(null); } } }; return cell; } }); }
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.OrganizerImpl.java
private void initializeFilesTree() { folderTree.setOnMouseClicked(event -> handleFolderChange()); folderTree.setCellFactory(treeView -> { HBox hbox = new HBox(); hbox.setMaxWidth(200);// w w w.ja va 2 s . c om hbox.setPrefWidth(200); hbox.setSpacing(7); FontAwesomeIconView openFolderIcon = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_OPEN_ALT); openFolderIcon.setTranslateY(7); FontAwesomeIconView closedFolderIcon = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_ALT); closedFolderIcon.setTranslateY(7); Label dirName = new Label(); dirName.setMaxWidth(150); FontAwesomeIconView removeIcon = new FontAwesomeIconView(FontAwesomeIcon.REMOVE); Tooltip deleteToolTip = new Tooltip(); deleteToolTip.setText("Verzeichnis aus Workspace entfernen"); Button button = new Button(null, removeIcon); button.setTooltip(deleteToolTip); button.setTranslateX(8); return new TreeCell<String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setGraphic(null); setText(null); } else if (getTreeItem() instanceof FilePathTreeItem) { hbox.getChildren().clear(); dirName.setText(item); if (getTreeItem().isExpanded()) { hbox.getChildren().add(openFolderIcon); } else { hbox.getChildren().add(closedFolderIcon); } hbox.getChildren().add(dirName); TreeItem<String> treeItem = getTreeItem(); TreeItem<String> parent = treeItem != null ? treeItem.getParent() : null; if (parent != null && parent.equals(folderTree.getRoot())) { String path = ((FilePathTreeItem) getTreeItem()).getFullPath(); button.setOnAction(event -> handleDeleteDirectory(Paths.get(path))); hbox.getChildren().add(button); } setGraphic(hbox); } } }; }); }
From source file:fruitproject.FruitProject.java
public void second(final String pfname) { final Stage st = new Stage(); Scene scene = null;/*from w ww. j ava2 s. co m*/ final GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); TableView tv = new TableView(); final TableColumn<Map, String> firstDataColumn = new TableColumn<>("Name"); final TableColumn<Map, String> secondDataColumn = new TableColumn<>("Amount"); final TableColumn<Map, String> thirdDataColumn = new TableColumn<>("Remove"); firstDataColumn.setMinWidth(130); secondDataColumn.setMinWidth(130); thirdDataColumn.setMinWidth(130); if (!pfname.equals("")) { firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey)); secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey)); thirdDataColumn.setCellValueFactory(new MapValueFactory(Column3MapKey)); rows = 0; tv = new TableView<>(generateDataInMap(pfname, addPairs)); } tv.getColumns().setAll(firstDataColumn, secondDataColumn, thirdDataColumn); // secondDataColumn.setCellFactory(TextFieldTableCell.forTableColumn()); ScrollPane sp = new ScrollPane(); sp.setMinWidth(400); sp.setHbarPolicy(ScrollBarPolicy.NEVER); sp.setContent(tv); grid.add(sp, 0, 3); final ComboBox comboBox = new ComboBox(); HBox hb1 = new HBox(); comboBox.setValue("FILE"); comboBox.getItems().addAll("Save this file", "Load a new file"); Button btnOk = new Button(); btnOk.setText("OK"); hb1.getChildren().addAll(comboBox, btnOk); hb1.setSpacing(10); grid.add(hb1, 0, 1); Label label1 = new Label("Title:"); final TextField tfFilename = new TextField(); tfFilename.setText(getTitle(pfname)); HBox hb = new HBox(); hb.getChildren().addAll(label1, tfFilename); hb.setSpacing(10); grid.add(hb, 0, 2); final Stage ps = new Stage(); final TableView tv1 = tv; btnOk.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); if (comboBox.getValue().equals("Load a new file")) { first(ps); st.close(); } else { PrintWriter pw = null; try { pw = new PrintWriter("abc.json"); BufferedWriter bw = new BufferedWriter(new FileWriter(pfname, false)); bw.write("{title:\"" + tfFilename.getText() + "\""); bw.write(",fruits:["); for (int i = 0; i < rows; i++) { bw.write("{name:\"" + String.valueOf(firstDataColumn.getCellData(i)) + "\",amount:" + String.valueOf(secondDataColumn.getCellData(i)) + "}"); if (i != rows - 1) bw.write(","); } bw.write("]}"); bw.close(); } catch (Exception e) { System.out.println(e.toString()); } } } }); Button btn = new Button(); btn.setText("New Fruit"); grid.add(btn, 1, 2); // TableView tv=new TableView(); // TableColumn Col1 = new TableColumn("Name"); // TableColumn Col2 = new TableColumn("Amount"); // TableColumn Col3 = new TableColumn("Remove"); // tv.getColumns().addAll(Col1, Col2, Col3); //sp.setFitToWidth(true); Image img = new Image("file:music.jpg"); ImageView iv2 = new ImageView(); iv2.setImage(img); iv2.setFitWidth(200); iv2.setPreserveRatio(true); iv2.setSmooth(true); iv2.setCache(true); grid.add(iv2, 1, 3); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); System.out.println(comboBox.valueProperty()); st.close(); third(pfname); } }); scene = new Scene(grid, 700, 450); st.setScene(scene); st.show(); }
From source file:io.bitsquare.gui.main.overlays.Overlay.java
protected void addCloseButton() { closeButton = new Button(closeButtonText == null ? "Close" : closeButtonText); closeButton.setOnAction(event -> doClose()); if (actionHandlerOptional.isPresent() || actionButtonText != null) { actionButton = new Button(actionButtonText == null ? "Ok" : actionButtonText); actionButton.setDefaultButton(true); //TODO app wide focus //actionButton.requestFocus(); actionButton.setOnAction(event -> { hide();/*www . j a v a 2s. c o m*/ actionHandlerOptional.ifPresent(Runnable::run); }); Pane spacer = new Pane(); HBox hBox = new HBox(); hBox.setSpacing(10); hBox.getChildren().addAll(spacer, closeButton, actionButton); HBox.setHgrow(spacer, Priority.ALWAYS); GridPane.setHalignment(hBox, HPos.RIGHT); GridPane.setRowIndex(hBox, ++rowIndex); GridPane.setColumnSpan(hBox, 2); GridPane.setMargin(hBox, new Insets(buttonDistance, 0, 0, 0)); gridPane.getChildren().add(hBox); } else if (!hideCloseButton) { closeButton.setDefaultButton(true); GridPane.setHalignment(closeButton, HPos.RIGHT); if (!showReportErrorButtons) GridPane.setMargin(closeButton, new Insets(buttonDistance, 0, 0, 0)); GridPane.setRowIndex(closeButton, ++rowIndex); GridPane.setColumnIndex(closeButton, 1); gridPane.getChildren().add(closeButton); } }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void openAccountManager() { //Window Crap Stage accountManagerStage = new Stage(); accountManagerStage.setTitle("Starbound Server Account Manager"); GridPane gp = new GridPane(); gp.setAlignment(Pos.CENTER);//from ww w. j ava 2 s . c o m gp.setVgap(10); gp.setHgap(10); gp.setPadding(new Insets(25, 25, 25, 25)); Text title = new Text("Starbound Account Manager"); title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(title, 0, 0, 2, 1); ListView<String> user_list = new ListView<String>(); ObservableList<String> user_list_o = FXCollections.observableArrayList(users); user_list.setItems(user_list_o); user_list.setPrefHeight(50); ListView<String> banned_users_list = new ListView<String>(); ObservableList<String> banned_users_list_o = FXCollections.observableArrayList(banned_usernames); banned_users_list.setItems(banned_users_list_o); banned_users_list.setPrefHeight(50); ListView<String> banned_ips_list = new ListView<String>(); ObservableList<String> banned_ips_list_o = FXCollections.observableArrayList(banned_ips); banned_ips_list.setItems(banned_ips_list_o); banned_ips_list.setPrefHeight(50); ListView<String> banned_playernames_list = new ListView<String>(); ObservableList<String> banned_playernames_list_o = FXCollections.observableArrayList(banned_playernames); banned_playernames_list.setItems(banned_playernames_list_o); banned_playernames_list.setPrefHeight(50); Label user_list_l = new Label("Current Users"); Label banned_users_list_l = new Label("Banned Users"); Label banned_ips_list_l = new Label("Banned IP's"); Label banned_playernames_list_l = new Label("Banned Player Names"); Button add_user = new Button("Add User"); Button add_banned_user = new Button("Add Banned User"); Button add_banned_ip = new Button("Add Banned IP"); Button add_banned_playername = new Button("Add Banner Playername"); Button remove_user = new Button("Remove User"); Button remove_banned_user = new Button("Remove Banned User"); Button remove_banned_ip = new Button("Remove Banned IP"); Button remove_banned_playername = new Button("Remove Banner Playername"); HBox userbox = new HBox(); userbox.setAlignment(Pos.BOTTOM_LEFT); userbox.getChildren().addAll(add_user, remove_user); userbox.setSpacing(5); HBox b_userbox = new HBox(); b_userbox.setAlignment(Pos.BOTTOM_LEFT); b_userbox.getChildren().addAll(add_banned_user, remove_banned_user); b_userbox.setSpacing(5); HBox b_ipbox = new HBox(); b_ipbox.setAlignment(Pos.BOTTOM_LEFT); b_ipbox.getChildren().addAll(add_banned_ip, remove_banned_ip); b_ipbox.setSpacing(5); HBox b_playerbox = new HBox(); b_playerbox.setAlignment(Pos.BOTTOM_LEFT); b_playerbox.getChildren().addAll(add_banned_playername, remove_banned_playername); b_playerbox.setSpacing(5); Button save = new Button("Save Config"); save.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { save(); } }); add_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createAccount(user_list); } }); add_banned_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedUser(banned_users_list); } }); add_banned_ip.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedIP(banned_ips_list); } }); add_banned_playername.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedPlayername(banned_playernames_list); } }); remove_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { users.remove(user_list.getSelectionModel().getSelectedItem()); user_list.setItems(FXCollections.observableArrayList(users)); } }); remove_banned_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_usernames.remove(banned_users_list.getSelectionModel().getSelectedItem()); banned_users_list.setItems(FXCollections.observableArrayList(banned_usernames)); } }); remove_banned_ip.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_ips.remove(banned_ips_list.getSelectionModel().getSelectedItem()); banned_ips_list.setItems(FXCollections.observableArrayList(banned_ips)); } }); remove_banned_playername.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_playernames.remove(banned_playernames_list.getSelectionModel().getSelectedItem()); banned_playernames_list.setItems(FXCollections.observableArrayList(banned_playernames)); } }); gp.add(user_list_l, 0, 1); gp.add(user_list, 0, 2); gp.add(userbox, 0, 3); gp.add(banned_users_list_l, 0, 4); gp.add(banned_users_list, 0, 5); gp.add(b_userbox, 0, 6); gp.add(banned_ips_list_l, 0, 7); gp.add(banned_ips_list, 0, 8); gp.add(b_ipbox, 0, 9); gp.add(banned_playernames_list_l, 0, 10); gp.add(banned_playernames_list, 0, 11); gp.add(b_playerbox, 0, 12); gp.add(save, 0, 13); Scene sc = new Scene(gp, 800 / 2, 600); accountManagerStage.setScene(sc); accountManagerStage.show(); }
From source file:gov.va.isaac.sync.view.SyncView.java
private void initGui() { root_ = new BorderPane(); root_.setPrefWidth(550);//from w w w . j a v a2s. c o m VBox titleBox = new VBox(); Label title = new Label("Datastore Synchronization"); title.getStyleClass().add("titleLabel"); title.setAlignment(Pos.CENTER); title.setMaxWidth(Double.MAX_VALUE); title.setPadding(new Insets(10)); titleBox.getChildren().add(title); titleBox.getStyleClass().add("headerBackground"); url_ = AppContext.getAppConfiguration().getCurrentChangeSetUrl(); String urlType = AppContext.getAppConfiguration().getChangeSetUrlTypeName(); String syncUsername = ExtendedAppContext.getCurrentlyLoggedInUserProfile().getSyncUsername(); if (StringUtils.isBlank(syncUsername)) { syncUsername = ExtendedAppContext.getCurrentlyLoggedInUser(); } url_ = syncService_.substituteURL(url_, syncUsername); Label info = new CopyableLabel("Sync using " + urlType + ": " + url_); info.setTooltip(new Tooltip(url_)); titleBox.getChildren().add(info); titleBox.setPadding(new Insets(5, 5, 5, 5)); root_.setTop(titleBox); VBox centerContent = new VBox(); centerContent.setFillWidth(true); centerContent.setPrefWidth(Double.MAX_VALUE); centerContent.setPadding(new Insets(10)); centerContent.getStyleClass().add("itemBorder"); centerContent.setSpacing(10.0); centerContent.getChildren().add(new Label("Status:")); summary_ = new TextArea(); summary_.setWrapText(true); summary_.setEditable(false); summary_.setMaxWidth(Double.MAX_VALUE); summary_.setMaxHeight(Double.MAX_VALUE); summary_.setPrefHeight(150.0); centerContent.getChildren().add(summary_); VBox.setVgrow(summary_, Priority.ALWAYS); pb_ = new ProgressBar(0.0); pb_.setPrefHeight(20); pb_.setMaxWidth(Double.MAX_VALUE); centerContent.getChildren().add(pb_); root_.setCenter(centerContent); //Bottom buttons HBox buttons = new HBox(); buttons.setMaxWidth(Double.MAX_VALUE); buttons.setAlignment(Pos.CENTER); buttons.setPadding(new Insets(5)); buttons.setSpacing(30); Button cancel = new Button("Close"); cancel.setOnAction((action) -> { if (running_.get()) { addLine("Cancelling..."); cancel.setDisable(true); cancelRequested_ = true; } else { cancel.getScene().getWindow().hide(); root_ = null; } }); buttons.getChildren().add(cancel); Button action = new Button("Synchronize"); action.disableProperty().bind(running_); action.setOnAction((theAction) -> { summary_.setText(""); pb_.setProgress(-1.0); running_.set(true); Utility.execute(() -> sync()); }); buttons.getChildren().add(action); cancel.minWidthProperty().bind(action.widthProperty()); running_.addListener(change -> { if (running_.get()) { cancel.setText("Cancel"); } else { cancel.setText("Close"); } cancel.setDisable(false); }); root_.setBottom(buttons); }