List of usage examples for javafx.scene.layout GridPane getChildren
@Override
public ObservableList<Node> getChildren()
From source file:gov.va.isaac.gui.util.ErrorMarkerUtils.java
/** * Useful when taking a node already placed by a fxml file, for example, and wrapping it * in a stack pane/* w w w . j av a 2 s. co m*/ * WARNING - the mechanism of moving the properties isn't currently very smart - it should only target * GridPane properties, but it takes everything. * * @return the replacementNode */ public static Node swapGridPaneComponents(Node placedNode, Node replacementNode, GridPane gp) { int index = gp.getChildren().indexOf(placedNode); if (index < 0) { throw new RuntimeException("Placed Node is not in the grid pane"); } gp.getChildren().remove(index); gp.getChildren().add(index, replacementNode); //this transfers the node specific constraints replacementNode.getProperties().putAll(placedNode.getProperties()); return replacementNode; }
From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginViewController.java
private static int getNumGridPaneRows(GridPane gridPane) { int numGridPaneRows = 0; for (javafx.scene.Node node : gridPane.getChildren()) { if (node != null) { Integer rowIndex = GridPane.getRowIndex(node); if (rowIndex != null && rowIndex >= numGridPaneRows) { ++numGridPaneRows;//w w w . j a v a 2s .c om } } } return numGridPaneRows; }
From source file:gov.va.isaac.gui.listview.operations.RefsetValueUtils.java
protected void remove(GridPane gp) { gp.getChildren().remove(refsetTypeLabel_); gp.getChildren().remove(refsetType_); gp.getChildren().remove(valueLabel_); gp.getChildren().remove(swappable);/*ww w . j a va 2 s .co m*/ }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 600, 400); stage.setScene(scene);/* w w w . j ava2 s .co m*/ stage.setTitle("Slider Sample"); GridPane grid = new GridPane(); grid.setPadding(new Insets(10, 10, 10, 10)); grid.setVgap(10); grid.setHgap(70); scene.setRoot(grid); GridPane.setConstraints(opacityCaption, 0, 1); grid.getChildren().add(opacityCaption); opacityLevel.valueProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { System.out.println(new_val.doubleValue()); opacityValue.setText(String.format("%.2f", new_val)); } }); GridPane.setConstraints(opacityLevel, 1, 1); grid.getChildren().add(opacityLevel); GridPane.setConstraints(opacityValue, 2, 1); grid.getChildren().add(opacityValue); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 500, 200); stage.setScene(scene);//w w w . java 2 s . co m GridPane grid = new GridPane(); grid.setPadding(new Insets(10, 10, 10, 10)); grid.setVgap(2); grid.setHgap(5); scene.setRoot(grid); caption.setFont(Font.font("Verdana", 20)); GridPane.setConstraints(caption, 0, 0); GridPane.setColumnSpan(caption, 8); grid.getChildren().add(caption); final Separator sepHor = new Separator(); sepHor.setValignment(VPos.CENTER); GridPane.setConstraints(sepHor, 0, 1); GridPane.setColumnSpan(sepHor, 7); grid.getChildren().add(sepHor); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 300, 150); stage.setScene(scene);//from w ww .ja va2 s. c om stage.setTitle("Text Field Sample"); GridPane grid = new GridPane(); grid.setPadding(new Insets(10, 10, 10, 10)); grid.setVgap(5); grid.setHgap(5); scene.setRoot(grid); final TextField name = new TextField(); name.setPromptText("Enter your first name."); name.setPrefColumnCount(10); name.getText(); GridPane.setConstraints(name, 0, 0); grid.getChildren().add(name); stage.show(); }
From source file:ipat_fx.FXMLDocumentController.java
@FXML public void resetScores() { HashMap<String, Hint> hintMap = controller.hints; TabPane tabpane = (TabPane) byProfilePane.getChildren().get(0); Tab tab = null;// w w w .j a v a2 s. c om if (tabFlag.equalsIgnoreCase("byProfile")) { tab = tabpane.getTabs().get(0); } else if (tabFlag.equalsIgnoreCase("byImage")) { tab = tabpane.getTabs().get(0); } else { Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, "Something wrong with tabFlag"); } ScrollPane scrollPane = (ScrollPane) tab.getContent(); FlowPane flowPane = (FlowPane) scrollPane.getContent(); Iterator<Node> cellsIterator = flowPane.getChildren().iterator(); while (cellsIterator.hasNext()) { GridPane cell = (GridPane) cellsIterator.next(); Iterator<Node> cellIterator = cell.getChildren().iterator(); while (cellIterator.hasNext()) { Node cellElement = cellIterator.next(); if (cellElement instanceof Slider) { Set<String> keySet = hintMap.keySet();// get the hints one by one and apply to cell int keyCount = 0; for (String key : keySet) { Hint h = hintMap.get(key); Slider slider = ((Slider) cellElement); String[] split = slider.getId().split("_"); if (split[0].equalsIgnoreCase(h.getHintName())) { slider.setValue(Double.valueOf(h.getDefaultValue())); } } } if (cellElement instanceof CheckBox) { ((CheckBox) cellElement).setSelected(false); } } } }
From source file:ipat_fx.FXMLDocumentController.java
@FXML public void nextGeneration() { //check if num of profiles is a valid input int numOfProfiles = Integer.parseInt(noOfProfiles.getText()); if (numOfProfiles > 8) { JOptionPane.showMessageDialog(null, "Please make the number of profiles smaller than 8."); } else {//from www . jav a 2 s. c om HashMap<String, Object> scores = new HashMap<>(); // TODO get the scores from the user input to then get the next gen ObservableList<Tab> tabs = null; if (tabFlag.equalsIgnoreCase("byImage")) { tabs = byImageTab.getTabs(); } else if (tabFlag.equalsIgnoreCase("byProfile")) { tabs = byProfileTab.getTabs(); } else { System.out.println("Something is wrong with tabFlag in FXML DOC CONT"); } Iterator<Tab> profileTabIterator = tabs.iterator(); while (profileTabIterator.hasNext()) { Tab profileTab = profileTabIterator.next(); ScrollPane scrollPane = (ScrollPane) profileTab.getContent(); FlowPane cells = (FlowPane) scrollPane.getContent(); Iterator<Node> cellIterator = cells.getChildren().iterator(); while (cellIterator.hasNext()) { GridPane cell = (GridPane) cellIterator.next(); Iterator<Node> nodeIterator = cell.getChildren().iterator(); while (nodeIterator.hasNext()) { Node cellElement = nodeIterator.next(); if (cellElement instanceof Slider) { scores.put(cellElement.getId(), String.valueOf(((Slider) cellElement).getValue())); } if (cellElement instanceof CheckBox) { scores.put(cellElement.getId(), ((CheckBox) cellElement).isSelected()); } } } } HashMap<String, Object> display = controller.mainloop(scores, numOfProfiles); WebView previewView = (WebView) display.get("previewView"); previewPane.getChildren().add(previewView); @SuppressWarnings("unchecked") HashMap<String, ArrayList<GridPane>> map = (HashMap<String, ArrayList<GridPane>>) display .get("results"); if (tabFlag.equalsIgnoreCase("byImage")) { byImageTab = getByImage(map); byImagePane.setCenter(byImageTab); } else if (tabFlag.equalsIgnoreCase("byProfile")) { byProfileTab = getByProfile(map, numOfProfiles); byProfilePane.setCenter(byProfileTab); } tabPane.getSelectionModel().selectedIndexProperty() .addListener((ObservableValue<? extends Number> ov, Number oldValue, Number newValue) -> { if (newValue == Number.class.cast(1)) { byImageTab = getByImage(map); byImagePane.setCenter(byImageTab); } else if (newValue == Number.class.cast(0)) { byProfileTab = getByProfile(map, numOfProfiles); byProfilePane.setCenter(byProfileTab); } else { System.out.println("Error this tab has not been created."); } }); } }
From source file:FeeBooster.java
private GridPane rbfGrid(Transaction tx) { // Setup grid GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);//ww w . jav a 2 s .co m grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); int inGridHeight = 0; int outGridHeight = 0; // Add inputs to table Label inputHdrLbl = new Label("Inputs"); grid.add(inputHdrLbl, 0, inGridHeight); inGridHeight++; for (int i = 0; i < tx.getInputs().size(); i++) { // Add input to table TxInput in = tx.getInputs().get(i); Text inputTxt = new Text("Txid: " + in.getTxid() + "\nIndex: " + in.getVout()); grid.add(inputTxt, 0, inGridHeight); inGridHeight++; } // Add outputs to table Label outputHdrLbl = new Label("Outputs"); grid.add(outputHdrLbl, 1, outGridHeight); outGridHeight++; ToggleGroup outputGroup = new ToggleGroup(); for (int i = 0; i < tx.getOutputs().size(); i++) { // Add output to table TxOutput out = tx.getOutputs().get(i); Text outputTxt = new Text("Amount " + out.getValue() + " Satoshis\nAddress: " + out.getAddress()); outputTxt.setUserData(i); grid.add(outputTxt, 1, outGridHeight); // Add radio button to table RadioButton radio = new RadioButton(); radio.setUserData(i); radio.setToggleGroup(outputGroup); radio.setSelected(true); grid.add(radio, 2, outGridHeight); outGridHeight++; } // Set gridheight int gridheight = (inGridHeight < outGridHeight) ? outGridHeight : inGridHeight; gridheight++; // Fee Text fee = new Text("Fee Paid: " + tx.getFee() + " Satoshis"); grid.add(fee, 0, gridheight); // Recommended fee from bitcoinfees.21.co JSONObject apiResult = Utils.getFromAnAPI("http://bitcoinfees.21.co/api/v1/fees/recommended", "GET"); int fastestFee = apiResult.getInt("fastestFee"); long recommendedFee = fastestFee * tx.getSize(); Text recFeeTxt = new Text("Recommended Fee: " + recommendedFee + " Satoshis"); grid.add(recFeeTxt, 1, gridheight); gridheight += 2; // Instructions Text instructions = new Text( "Choose an output to deduct an additional fee from. Then increase the fee below."); grid.add(instructions, 0, gridheight, 3, 1); gridheight++; // Fee spinner Spinner feeSpin = new Spinner((double) tx.getFee(), (double) tx.getTotalAmt(), (double) tx.getFee()); feeSpin.setEditable(true); grid.add(feeSpin, 0, gridheight); feeSpin.valueProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { double oldVal = (double) oldValue; double newVal = (double) newValue; Double step = newVal - oldVal; tx.setFee(tx.getFee() + step.longValue()); fee.setText("Fee Paid: " + tx.getFee() + " Satoshis"); int output = (int) outputGroup.getSelectedToggle().getUserData(); TxOutput out = tx.getOutputs().get(output); out.decreaseValueBy(step.longValue()); for (int i = 0; i < grid.getChildren().size(); i++) { Node child = grid.getChildren().get(i); if (grid.getRowIndex(child) == output + 1 && grid.getColumnIndex(child) == 1) { ((Text) child) .setText("Amount " + out.getValue() + " Satoshis\nAddress: " + out.getAddress()); } } } }); // Set to recommended fee button Button recFeeBtn = new Button("Set fee to recommended"); grid.add(recFeeBtn, 1, gridheight); gridheight++; recFeeBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { long prevFee = tx.getFee(); long step = recommendedFee - prevFee; feeSpin.increment((int) step); } }); // Next Button Button nextBtn = new Button("Next"); grid.add(nextBtn, 1, gridheight); nextBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { if (sceneCursor == scenes.size() - 1) { Scene scene = new Scene(unsignedTxGrid(tx), 900, 500); scenes.add(scene); sceneCursor++; stage.setScene(scene); } else { sceneCursor++; stage.setScene(scenes.get(sceneCursor)); } } }); HBox btnHbox = new HBox(10); // Back Button Button backBtn = new Button("Back"); backBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { sceneCursor--; stage.setScene(scenes.get(sceneCursor)); } }); btnHbox.getChildren().add(backBtn); btnHbox.getChildren().add(nextBtn); // Cancel Button Button cancelBtn = new Button("Cancel"); cancelBtn.setOnAction(cancelEvent); btnHbox.getChildren().add(cancelBtn); grid.add(btnHbox, 1, gridheight); return grid; }