List of usage examples for javafx.scene.layout HBox getChildren
@Override
public ObservableList<Node> getChildren()
From source file:ch.tuason.djbattlescore.lib.components.comps.ResultGridPane.java
/** * adds a certain DjEntity to the ranking grid panel... * //from ww w .ja v a2 s. co m * @param results a Collection of DjEntity... */ public void addCurrentDJRanking(Collection<DjEntity> results) { this.addedRankingComponents.clear(); this.currentDjRanking = results; if (this.currentDjRanking != null && !this.currentDjRanking.isEmpty()) { int iPos = 1; for (DjEntity dj : this.currentDjRanking) { Image djImage = null; if (!StringUtils.isEmpty(dj.getAvatarPicPath32())) { djImage = getImageFromCache(dj); if (djImage == null) { try { djImage = new Image(getClass().getResourceAsStream( DjBattleConstants.IMAGE_RESOURCE_BASE_FOR_DJ_PICS + dj.getAvatarPicPath32())); if (!djImage.isError()) { imageCache.put(dj.getId(), djImage); } } catch (Exception e) { System.out.println("the image for dj '" + dj.getName() + "' could not be loaded for the avatar image... " + e.getMessage()); djImage = null; } } // it might be an absolute path? if (djImage == null) { try { djImage = new Image( DjBattleConstants.ABSOLUTE_IMAGE_FILEPATH_PREFIX + dj.getAvatarPicPath32()); if (!djImage.isError()) { imageCache.put(dj.getId(), djImage); } } catch (Exception e) { System.out.println("the image for dj '" + dj.getName() + "' could not be loaded for the avatar image... " + e.getMessage()); djImage = null; } } if (djImage == null) { djImage = getStandardImage(); } } if (StringUtils.isEmpty(dj.getAvatarPicPath32()) || djImage == null) { djImage = getStandardImage(); } HBox djComponent = new HBox(); djComponent.setPadding(new Insets(5, 0, 0, 20)); Label djLabel = new Label(dj.getDjNameWithSoundStyle(), new ImageView(djImage)); djLabel.setFont(new Font("Arial", 20)); // component.setTextFill(Color.web(DjBattleConstants.COLOR_RESULT_TITLE_TEXT)); djComponent.getChildren().add(djLabel); this.addedRankingComponents.add(djComponent); this.add(djComponent, 0, iPos); iPos++; } } }
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 v a 2 s . c o m 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: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);/*from w w w. j a va 2s . c o m*/ Button buttonProjected = new Button("Projected"); buttonProjected.setPrefSize(100, 20); hbox.getChildren().addAll(buttonCurrent, buttonProjected); return hbox; }
From source file:mesclasses.view.TimetableController.java
private VBox createEvent(Cours theCours) { VBox event = new VBox(); CssUtil.addClass(event, "event"); CssUtil.addClass(event, getCSS(theCours)); String periodicite = theCours.getWeek().equals(config.getProperty(Constants.CONF_WEEK_DEFAULT)) ? "" : theCours.getWeek();// www . j a va2s . c o m String salle = StringUtils.isNotBlank(theCours.getRoom()) ? "salle " + theCours.getRoom() : ""; Label periodiciteAndSalle = new Label((periodicite + " " + salle).trim()); bindWidth(periodiciteAndSalle, event, 1); Label classe = new Label(theCours.getClasse().getName()); CssUtil.addClass(classe, "event-classe"); bindWidth(classe, event, 1); //horaires HBox horaires = new HBox(); CssUtil.addClass(horaires, "horaires"); Label start = new Label(" " + NodeUtil.getStartTime(theCours)); CssUtil.addClass(start, "start"); Label end = new Label(NodeUtil.getEndTime(theCours) + " "); CssUtil.addClass(end, "end"); horaires.getChildren().add(start); horaires.getChildren().add(end); bindWidth(horaires, event, 1); bindWidth(start, horaires, 2); bindWidth(end, horaires, 2); event.getChildren().add(periodiciteAndSalle); bindHeight(periodiciteAndSalle, event, 3); event.getChildren().add(classe); bindHeight(classe, event, 3); event.getChildren().add(horaires); bindHeight(horaires, event, 3); event.setOnMouseReleased((e) -> { handleEditCours(theCours); }); theCours.setEvent(event); return event; }
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private void addSeparator() { final HBox bb = new HBox(); bb.setPrefHeight(20);/*ww w. j a va2 s. co m*/ bb.setAlignment(Pos.CENTER); final Separator s = new Separator(); s.getStyleClass().add("large-separator"); bb.getChildren().add(s); HBox.setHgrow(s, Priority.ALWAYS); content.getChildren().add(bb); }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void createAccount(ListView<String> to_update) { Stage createAccountStage = new Stage(); createAccountStage.initModality(Modality.APPLICATION_MODAL); //Set the stage info createAccountStage.setTitle("Add Server Account"); //Create a layout GridPane gp = new GridPane(); gp.setAlignment(Pos.CENTER);//ww w.j ava 2 s. com gp.setVgap(10); gp.setHgap(10); gp.setPadding(new Insets(25, 25, 25, 25)); //Ads the important things Text welcome = new Text("Create Server Account"); welcome.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(welcome, 0, 0, 2, 1); Label username = new Label("Username"); Label password = new Label("Password"); Label r_password = new Label("Repeat Password"); TextField usernamefield = new TextField(); PasswordField passwordfield = new PasswordField(); PasswordField r_passwordfield = new PasswordField(); gp.add(username, 0, 1); gp.add(password, 0, 2); gp.add(r_password, 0, 3); gp.add(usernamefield, 1, 1); gp.add(passwordfield, 1, 2); gp.add(r_passwordfield, 1, 3); Text error = new Text(""); HBox error_box = new HBox(10); error_box.setAlignment(Pos.CENTER); error_box.getChildren().add(error); gp.add(error_box, 0, 4, 2, 1); Button finish = new Button("Finish"); finish.setDisable(true); HBox center_button = new HBox(10); center_button.setAlignment(Pos.CENTER); center_button.getChildren().add(finish); gp.add(center_button, 0, 5, 2, 1); ChangeListener name = new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { finish.setDisable(true); if (usernamefield.getText().equals("")) { error.setFill(Color.RED); error.setText("Username can not be blank!"); } if (!passwordfield.getText().equals(r_passwordfield.getText())) { error.setFill(Color.RED); error.setText("Passwords do not match!"); } if (passwordfield.getText().equals("") && r_passwordfield.getText().equals("")) { error.setFill(Color.RED); error.setText("Passwords can not be blank!"); } if (passwordfield.getText().equals(r_passwordfield.getText()) && !usernamefield.getText().equals("") && !passwordfield.getText().equals("")) { error.setFill(Color.GREEN); error.setText("No issues."); finish.setDisable(false); } } }; usernamefield.textProperty().addListener(name); passwordfield.textProperty().addListener(name); r_passwordfield.textProperty().addListener(name); finish.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { users.remove(usernamefield.getText()); users.add(usernamefield.getText()); userpasswords.put(usernamefield.getText(), passwordfield.getText()); to_update.setItems(FXCollections.observableArrayList(users)); createAccountStage.close(); } }); //Creates the scene Scene scene = new Scene(gp, 300, 275); scene.getStylesheets().add(this.getClass().getResource("login_css.css").toExternalForm()); createAccountStage.setScene(scene); createAccountStage.show(); }
From source file:fruitproject.FruitProject.java
public void second(final String pfname) { final Stage st = new Stage(); Scene scene = null;//from w w w . j ava2 s . c om 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:FeeBooster.java
@Override public void start(Stage primaryStage) throws Exception { // Setup the stage stage = primaryStage;//ww w . j a v a 2 s . co m primaryStage.setTitle("Bitcoin Transaction Fee Booster"); // Setup intro gridpane GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); // Intro Text Text scenetitle = new Text( "Welcome to the fee booster. \n\nWhat type of transaction would you like to boost the fee of?"); grid.add(scenetitle, 0, 0, 2, 3); // radio button selections VBox boostRadioVbox = new VBox(); ToggleGroup boostTypeGroup = new ToggleGroup(); RadioButton rbfRadio = new RadioButton("A transaction you sent"); rbfRadio.setToggleGroup(boostTypeGroup); boostRadioVbox.getChildren().add(rbfRadio); RadioButton cpfpRadio = new RadioButton("A transaction you received"); cpfpRadio.setToggleGroup(boostTypeGroup); rbfRadio.setSelected(true); boostRadioVbox.getChildren().add(cpfpRadio); grid.add(boostRadioVbox, 0, 3); // Instructions Text Text instruct = new Text("Please enter the raw hex or transaction id of your transaction below:"); grid.add(instruct, 0, 4); // Textbox for hex of transaction TextArea txHexTxt = new TextArea(); txHexTxt.setWrapText(true); grid.add(txHexTxt, 0, 5, 5, 1); // Next Button Button nextBtn = new Button("Next"); nextBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { // Create Transaction Transaction tx = new Transaction(); // Check if txid boolean isTxid = txHexTxt.getText().length() == 64 && txHexTxt.getText().matches("[0-9A-Fa-f]+"); if (isTxid) tx.setHash(txHexTxt.getText()); // Determine which page to go to if (Transaction.deserializeStr(txHexTxt.getText(), tx) || isTxid) { // Get the fee JSONObject apiResult = Utils .getFromAnAPI("https://api.blockcypher.com/v1/btc/main/txs/" + tx.getHash(), "GET"); // Get the fee tx.setFee(apiResult.getInt("fees")); tx.setTotalAmtPre(tx.getFee() + tx.getOutAmt()); // Get info if txid if (isTxid) { } Scene scene = null; if (rbfRadio.isSelected()) if (sceneCursor == scenes.size() - 1 || !rbf) { scene = new Scene(rbfGrid(tx), 900, 500); if (!rbf) { scenes.clear(); scenes.add(stage.getScene()); } rbf = true; } if (cpfpRadio.isSelected()) if (sceneCursor == scenes.size() - 1 || rbf) { scene = new Scene(cpfpGrid(tx), 900, 500); if (rbf) { scenes.clear(); scenes.add(stage.getScene()); } rbf = false; } if (sceneCursor != scenes.size() - 1) scene = scenes.get(sceneCursor + 1); else scenes.add(scene); sceneCursor++; stage.setScene(scene); } else { Alert alert = new Alert(Alert.AlertType.ERROR, "Please enter a valid transaction"); alert.showAndWait(); } } }); HBox btnHbox = new HBox(10); btnHbox.getChildren().add(nextBtn); // Cancel Button Button cancelBtn = new Button("Cancel"); cancelBtn.setOnAction(cancelEvent); btnHbox.getChildren().add(cancelBtn); grid.add(btnHbox, 2, 7); // Display everything Scene scene = new Scene(grid, 900, 500); scenes.add(scene); primaryStage.setScene(scene); primaryStage.show(); }
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);/*ww w .ja v a 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:account.management.controller.NewVoucherController.java
@FXML private void onSelectType(ActionEvent event) { filter_acc = FXCollections.observableArrayList(); for (int i = 0; i < this.account_list.size(); i++) { if (this.account_list.get(i).getAccount_type() .equals(this.select_type.getSelectionModel().getSelectedItem().getId()) && this.account_list.get(i).getId() > 57) { filter_acc.add(this.account_list.get(i)); }//from w ww .j a v a 2s . c o m } //this.account_list.clear(); for (int i = 0; i < this.field_container.getChildren().size(); i++) { HBox row = (HBox) this.field_container.getChildren().get(i); ComboBox<Account> combo = (ComboBox<Account>) row.getChildren().get(0); combo.getItems().clear(); combo.getItems().addAll(filter_acc); } }