Java Code Examples for javafx.scene.layout.GridPane#setAlignment()
The following examples show how to use
javafx.scene.layout.GridPane#setAlignment() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExampleCss.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 6 votes |
private void buildAndShowMainWindow(Stage primaryStage) { primaryStage.setTitle("Hello World!!"); GridPane gridPane = new GridPane(); gridPane.setAlignment(Pos.CENTER); gridPane.setHgap(10); gridPane.setVgap(10); gridPane.setPadding(new Insets(25, 25, 25, 25)); button = new Button("Click me!"); button.setId("TheButton"); gridPane.add(button,1,1); text = new TextField(); gridPane.add(text, 2, 1); clockLabel = new Label(); gridPane.add(clockLabel, 1,2, 2, 1); Scene scene = new Scene(gridPane); primaryStage.setScene(scene); scene.getStylesheets().add(getClass().getResource("/form.css").toExternalForm()); primaryStage.show(); }
Example 2
Source File: DotHTMLLabelJavaFxNode.java From gef with Eclipse Public License 2.0 | 6 votes |
private void applyTableAlignAttributesOnTdPane(GridPane wrapper) { /* * Graphviz documentation specifies for the ALIGN attribute on cells: If * the cell does not contain text, then the contained image or table is * centered. * * Further, by observation, unless the fixedsize attribute is set, in * graphviz the inner table grows in both horizontal and vertical * direction. * * TODO: revise these settings when the align attribute on table tags is * implemented, as this may change some behaviour. */ GridPane.setHgrow(wrapper.getChildren().get(0), Priority.ALWAYS); GridPane.setVgrow(wrapper.getChildren().get(0), Priority.ALWAYS); wrapper.setAlignment(Pos.CENTER); }
Example 3
Source File: ShortObjectEditorFactory.java From constellation with Apache License 2.0 | 6 votes |
@Override protected Node createEditorControls() { final GridPane controls = new GridPane(); controls.setAlignment(Pos.CENTER); controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING); numberField = new TextField(); numberField.textProperty().addListener((o, n, v) -> { update(); }); noValueCheckBox = new CheckBox(NO_VALUE_LABEL); noValueCheckBox.setAlignment(Pos.CENTER); noValueCheckBox.selectedProperty().addListener((v, o, n) -> { numberField.setDisable(noValueCheckBox.isSelected()); update(); }); controls.addRow(0, numberField); controls.addRow(1, noValueCheckBox); return controls; }
Example 4
Source File: RregulloPunen.java From Automekanik with GNU General Public License v3.0 | 5 votes |
public RregulloPunen(int id, ShikoPunetPunetoret spp, boolean kryer){ stage.initModality(Modality.APPLICATION_MODAL); stage.setResizable(false); stage.setTitle("Rregullo"); HBox btn = new HBox(5); btn.getChildren().addAll(btnOk, btnAnulo); btn.setAlignment(Pos.CENTER_RIGHT); GridPane grid = new GridPane(); grid.add(cbKryer, 0, 0); grid.add(btn, 0, 1); grid.setVgap(10); grid.setAlignment(Pos.CENTER); cbKryer.setSelected(kryer); btnOk.setOnAction(e -> { azhurno(id); new Thread(new Runnable() { @Override public void run() { spp.mbushNgaStatusi(spp.lblEmri.getText()); } }).start(); }); btnAnulo.setOnAction(e -> stage.close()); Scene scene = new Scene(grid, 230, 100); scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm()); stage.setScene(scene); stage.show(); }
Example 5
Source File: EditAxis.java From chart-fx with Apache License 2.0 | 5 votes |
/** * Creates the header for the Axis Editor popup, allowing to configure axis label and unit * * @param axis The axis to be edited * @return pane containing label, label editor and unit editor */ private Node getLabelEditor(final Axis axis, final boolean isHorizontal) { final GridPane header = new GridPane(); header.setAlignment(Pos.BASELINE_LEFT); final TextField axisLabelTextField = new TextField(axis.getName()); axisLabelTextField.textProperty().bindBidirectional(axis.nameProperty()); header.addRow(0, new Label(" axis label: "), axisLabelTextField); final TextField axisUnitTextField = new TextField(axis.getUnit()); axisUnitTextField.setPrefWidth(50.0); axisUnitTextField.textProperty().bindBidirectional(axis.unitProperty()); header.addRow(isHorizontal ? 0 : 1, new Label(" unit: "), axisUnitTextField); final TextField unitScaling = new TextField(); unitScaling.setPrefWidth(80.0); final CheckBox autoUnitScaling = new CheckBox(" auto"); if (axis instanceof DefaultNumericAxis) { autoUnitScaling.selectedProperty() .bindBidirectional(((DefaultNumericAxis) axis).autoUnitScalingProperty()); unitScaling.textProperty().bindBidirectional(((DefaultNumericAxis) axis).unitScalingProperty(), new NumberStringConverter(new DecimalFormat("0.0####E0"))); unitScaling.disableProperty().bind(autoUnitScaling.selectedProperty()); } else { // TODO: consider adding an interface on whether // autoUnitScaling is editable autoUnitScaling.setDisable(true); unitScaling.setDisable(true); } final HBox unitScalingBox = new HBox(unitScaling, autoUnitScaling); unitScalingBox.setAlignment(Pos.BASELINE_LEFT); header.addRow(isHorizontal ? 0 : 2, new Label(" unit scale:"), unitScalingBox); return header; }
Example 6
Source File: BoardNameDialog.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
private static void setupGridPane(GridPane grid) { grid.setAlignment(Pos.CENTER); grid.setHgap(5); grid.setVgap(5); grid.setPadding(new Insets(25)); grid.setPrefSize(360, 60); grid.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE); }
Example 7
Source File: Exercise_21_11.java From Intro-to-Java-Programming with MIT License | 5 votes |
/** Returns the ranking pane */ private BorderPane getPane() { // Add items to cboYear for (int i = 2001; i <= 2010; i++) cboYear.getItems().add(i + ""); // Add items to cboGender cboGender.getItems().addAll("Male", "Female"); // Create a grid pane GridPane gridPane = new GridPane(); gridPane.setVgap(5); gridPane.setPadding(new Insets(5, 0, 5, 0)); gridPane.setAlignment(Pos.CENTER); gridPane.add(new Label("Select a year: "), 0, 0); gridPane.add(cboYear, 1, 0); gridPane.add(new Label("Boy or girl?: "), 0, 1); gridPane.add(cboGender, 1, 1); gridPane.add(new Label("Enter a name: "), 0, 2); gridPane.add(tfName, 1, 2); gridPane.add(btFindRanking, 1, 3); // Create a border pane and place node in it BorderPane pane = new BorderPane(); pane.setCenter(gridPane); pane.setBottom(lblResults); pane.setAlignment(lblResults, Pos.CENTER); return pane; }
Example 8
Source File: SpectralMatchPanelFX.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
private GridPane createTitlePane() { pnTitle = new GridPane(); pnTitle.setAlignment(Pos.CENTER); // create Top panel double simScore = hit.getSimilarity().getScore(); Color gradientCol = FxColorUtil.awtColorToFX(ColorScaleUtil .getColor(FxColorUtil.fxColorToAWT(MIN_COS_COLOR), FxColorUtil.fxColorToAWT(MAX_COS_COLOR), MIN_COS_COLOR_VALUE, MAX_COS_COLOR_VALUE, simScore)); pnTitle.setBackground( new Background(new BackgroundFill(gradientCol, CornerRadii.EMPTY, Insets.EMPTY))); lblHit = new Label(hit.getName()); lblHit.getStyleClass().add("white-larger-label"); lblScore = new Label(COS_FORM.format(simScore)); lblScore.getStyleClass().add("white-score-label"); lblScore .setTooltip(new Tooltip("Cosine similarity of raw data scan (top, blue) and database scan: " + COS_FORM.format(simScore))); pnTitle.add(lblHit, 0, 0); pnTitle.add(lblScore, 1, 0); ColumnConstraints ccTitle0 = new ColumnConstraints(150, -1, -1, Priority.ALWAYS, HPos.LEFT, true); ColumnConstraints ccTitle1 = new ColumnConstraints(150, 150, 150, Priority.NEVER, HPos.LEFT, false); pnTitle.getColumnConstraints().add(0, ccTitle0); pnTitle.getColumnConstraints().add(1, ccTitle1); return pnTitle; }
Example 9
Source File: FxUtils.java From stagedisplayviewer with MIT License | 5 votes |
private GridPane createRoot(Text lowerKey) { GridPane root = new GridPane(); root.setHgap(10); root.setVgap(10); if ("top".equalsIgnoreCase(VERTICAL_ALIGN.toString())) { root.setAlignment(Pos.TOP_CENTER); } else if ("center".equalsIgnoreCase(VERTICAL_ALIGN.toString())) { root.setAlignment(Pos.CENTER); } else { root.setAlignment(Pos.BOTTOM_CENTER); } root.setPadding(new Insets(MARGIN_TOP.toInt(), 10, MARGIN_BOTTOM.toInt(), 10)); root.add(lowerKey, 0, 0, 2, 1); return root; }
Example 10
Source File: Exercise_15_05.java From Intro-to-Java-Programming with MIT License | 5 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create UI GridPane pane = new GridPane(); pane.setVgap(5); pane.setHgap(5); pane.add(new Label("Investment Amount:"), 0, 0); pane.add(tfInvestmentAmount, 1, 0); pane.add(new Label("Number Of Years:"), 0, 1); pane.add(tfNumberOfYears, 1, 1); pane.add(new Label("Annual Interest Rate:"), 0, 2); pane.add(tfAnnualInterestRate, 1, 2); pane.add(new Label("Future value:"), 0, 3); pane.add(tfFutureValue, 1, 3); pane.add(btCalculate, 1, 4); // Set UI properties pane.setAlignment(Pos.CENTER); tfInvestmentAmount.setAlignment(Pos.BOTTOM_RIGHT); tfNumberOfYears.setAlignment(Pos.BOTTOM_RIGHT); tfAnnualInterestRate.setAlignment(Pos.BOTTOM_RIGHT); tfFutureValue.setAlignment(Pos.BOTTOM_RIGHT); tfFutureValue.setEditable(false); pane.setHalignment(btCalculate, HPos.RIGHT); pane.setPadding(new Insets(10, 10, 10, 10)); // Process events btCalculate.setOnAction(e -> futureValue()); // Create a scene and place it in the stage Scene scene = new Scene(pane); primaryStage.setTitle("Exercise_15_05"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 11
Source File: RregulloPunen.java From Automekanik with GNU General Public License v3.0 | 5 votes |
public RregulloPunen(int id, boolean kryer, TeDhenat td){ stage.initModality(Modality.APPLICATION_MODAL); stage.setResizable(false); stage.setTitle("Rregullo"); HBox btn = new HBox(5); btn.getChildren().addAll(btnOk, btnAnulo); btn.setAlignment(Pos.CENTER_RIGHT); GridPane grid = new GridPane(); grid.add(cbKryer, 0, 0); grid.add(btn, 0, 1); grid.setVgap(10); grid.setAlignment(Pos.CENTER); cbKryer.setSelected(kryer); btnOk.setOnAction(e -> { azhurno(id); new Thread(new Runnable() { @Override public void run() { td.mbush(); } }).start(); }); btnAnulo.setOnAction(e -> stage.close()); Scene scene = new Scene(grid, 230, 100); scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm()); stage.setScene(scene); stage.show(); }
Example 12
Source File: Exercise_16_04.java From Intro-to-Java-Programming with MIT License | 5 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Set text fields alignment tfMile.setAlignment(Pos.BOTTOM_RIGHT); tfKilometer.setAlignment(Pos.BOTTOM_RIGHT); // Create a gridpane and place nodes into it GridPane pane = new GridPane(); pane.setAlignment(Pos.CENTER); pane.add(new Label("Mile"), 0, 0); pane.add(tfMile, 1, 0); pane.add(new Label("Kilometer"), 0, 1); pane.add(tfKilometer, 1, 1); // Create and register the handlers tfMile.setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ENTER && tfMile.getText().length() > 0) { double miles = Double.parseDouble(tfMile.getText()); tfKilometer.setText(String.valueOf(miles * KILOMETERS_PER_MILE)); } }); tfKilometer.setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ENTER && tfKilometer.getText().length() > 0) { double kilometers = Double.parseDouble(tfKilometer.getText()); tfMile.setText(String.valueOf(kilometers / KILOMETERS_PER_MILE)); } }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 250, 60); primaryStage.setTitle("Exercise_16_04"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 13
Source File: FilterBox.java From mcaselector with MIT License | 4 votes |
public FilterBox(FilterBox parent, Filter<?> filter, boolean root) { this.parent = parent; this.root = root; if (root) { getStyleClass().add("filter-box-root"); } getStyleClass().add("filter-box"); this.filter = filter; add.setTooltip(UIFactory.tooltip(Translation.DIALOG_FILTER_CHUNKS_FILTER_ADD_TOOLTIP)); add.getStyleClass().add("control-label"); delete.setTooltip(UIFactory.tooltip(Translation.DIALOG_FILTER_CHUNKS_FILTER_DELETE_TOOLTIP)); delete.getStyleClass().add("control-label"); GridPane controls = new GridPane(); controls.getStyleClass().add("filter-controls-grid"); controls.setAlignment(Pos.TOP_RIGHT); controls.add(add, 0, 0, 1, 1); controls.add(delete, 1, 0, 1, 1); controls.add(move, 2, 0, 1, 1); setOnDragDetected(this::onDragDetected); setOnDragOver(this::onDragOver); setOnDragDone(this::onDragDone); setOnDragDropped(this::onDragDropped); setOnDragExited(this::onDragExited); setOnDragEntered(this::onDragEntered); setRight(controls); filterOperators.getStyleClass().add("filter-operators-grid"); type.setTooltip(UIFactory.tooltip(Translation.DIALOG_FILTER_CHUNKS_FILTER_TYPE_TOOLTIP)); type.getItems().addAll(FilterType.values()); type.getSelectionModel().select(filter.getType()); type.setOnAction(e -> update(type.getSelectionModel().getSelectedItem())); type.getStyleClass().add("filter-type-combo-box"); filterOperators.add(type, 1, 0, 1, 1); operator.setTooltip(UIFactory.tooltip(Translation.DIALOG_FILTER_CHUNKS_FILTER_OPERATOR_TOOLTIP)); operator.getItems().addAll(Operator.values()); operator.getSelectionModel().select(filter.getOperator()); operator.setOnAction(e -> onOperator(filter)); operator.getStyleClass().add("filter-operator-combo-box"); filterOperators.add(operator, 0, 0, 1, 1); if (filter.getParent() == null || ((GroupFilter) filter.getParent()).getFilterValue().get(0) == filter) { operator.setVisible(false); } filterOperators.setAlignment(Pos.TOP_LEFT); setLeft(filterOperators); add.setOnMouseReleased(e -> onAdd(filter)); delete.setOnMouseReleased(e -> onDelete(filter)); }
Example 14
Source File: AttributeEditorPanel.java From constellation with Apache License 2.0 | 4 votes |
private Node createAttributeValueNode(final Object[] values, final AttributeData attribute, final AttributeTitledPane parent, final boolean multiValue) { boolean noneSelected = values == null; boolean isNull = !noneSelected && (values[0] == null); parent.setAttribute(attribute); AbstractAttributeInteraction<?> interaction = AbstractAttributeInteraction.getInteraction(attribute.getDataType()); final String displayText; final List<Node> displayNodes; if (multiValue) { displayText = "<Multiple Values>"; displayNodes = Collections.emptyList(); } else if (isNull) { displayText = NO_VALUE_TEXT; displayNodes = Collections.emptyList(); } else if (noneSelected) { displayText = "<Nothing Selected>"; displayNodes = Collections.emptyList(); } else { displayText = interaction.getDisplayText(values[0]); displayNodes = interaction.getDisplayNodes(values[0], -1, CELL_ITEM_HEIGHT); } parent.setAttributeValue(displayText); final TextField attributeValueText = new TextField(displayText); attributeValueText.setEditable(false); if (noneSelected || isNull || multiValue) { attributeValueText.getStyleClass().add("undisplayedValue"); } if (displayNodes.isEmpty()) { return attributeValueText; } GridPane gridPane = new GridPane(); gridPane.setAlignment(Pos.CENTER_RIGHT); gridPane.setPadding(Insets.EMPTY); gridPane.setHgap(CELL_ITEM_SPACING); ColumnConstraints displayNodeConstraint = new ColumnConstraints(CELL_ITEM_HEIGHT); displayNodeConstraint.setHalignment(HPos.LEFT); ColumnConstraints displayTextConstraint = new ColumnConstraints(); displayTextConstraint.setHalignment(HPos.RIGHT); displayTextConstraint.setHgrow(Priority.ALWAYS); displayTextConstraint.setFillWidth(true); for (int i = 0; i < displayNodes.size(); i++) { final Node displayNode = displayNodes.get(i); gridPane.add(displayNode, i, 0); gridPane.getColumnConstraints().add(displayNodeConstraint); } gridPane.add(attributeValueText, displayNodes.size(), 0); gridPane.getColumnConstraints().add(displayTextConstraint); return gridPane; }
Example 15
Source File: Exercise31_06Client.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { GridPane pane = new GridPane(); pane.add(new Label("Name"), 0, 0); pane.add(tfName, 1, 0); pane.add(new Label("Street"), 0, 1); pane.add(tfStreet, 1, 1); pane.add(new Label("City"), 0, 2); // Hbox to store city, state and zip info HBox hBox = new HBox(5); pane.add(hBox, 1, 2); hBox.getChildren().addAll(tfCity, new Label("State"), tfState, new Label("Zip"), tfZip); // Hbox to hold buttons HBox paneForButtons = new HBox(5); paneForButtons.getChildren().addAll(btAdd, btFirst, btNext, btPrevious, btLast); pane.add(paneForButtons, 1, 3); pane.setHgap(5); pane.setVgap(5); pane.setAlignment(Pos.CENTER); tfName.setPrefColumnCount(15); tfState.setPrefColumnCount(15); tfCity.setPrefColumnCount(10); tfState.setPrefColumnCount(2); tfZip.setPrefColumnCount(3); // Register handlers btAdd.setOnAction(e -> addAddress()); btFirst.setOnAction(e -> getFirst()); btNext.setOnAction(e -> getNext()); btPrevious.setOnAction(e -> getPrevious()); btLast.setOnAction(e -> getLast()); // Create a scene and place it in the stage Scene scene = new Scene(pane, 375, 130); primaryStage.setTitle("Exercise31_06"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 16
Source File: Exercise_16_05.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Set text field preferences tfDecimal.setAlignment(Pos.BOTTOM_RIGHT); tfHex.setAlignment(Pos.BOTTOM_RIGHT); tfBinary.setAlignment(Pos.BOTTOM_RIGHT); // Create a grid pane and add nodes to it GridPane pane = new GridPane(); pane.setAlignment(Pos.CENTER); pane.setHgap(10); pane.setVgap(2); pane.add(new Label("Decimal"), 0, 0); pane.add(tfDecimal, 1, 0); pane.add(new Label("Hex"), 0, 1); pane.add(tfHex, 1, 1); pane.add(new Label("Binary"), 0, 2); pane.add(tfBinary, 1, 2); // Create and register handlers tfDecimal.setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ENTER) { tfHex.setText(Integer.toHexString( Integer.parseInt(tfDecimal.getText()))); tfBinary.setText(Integer.toBinaryString( Integer.parseInt(tfDecimal.getText()))); } }); tfHex.setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ENTER) { tfDecimal.setText(String.valueOf( Integer.parseInt(tfHex.getText(), 16))); tfBinary.setText(Integer.toBinaryString( Integer.parseInt(tfHex.getText(), 16))); } }); tfBinary.setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ENTER) { tfDecimal.setText(String.valueOf( Integer.parseInt(tfBinary.getText(), 2))); tfHex.setText(Integer.toHexString( Integer.parseInt(tfBinary.getText(), 2))); } }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 250, 100); primaryStage.setTitle("Exercise_16_05"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 17
Source File: IconEditorFactory.java From constellation with Apache License 2.0 | 4 votes |
@Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (item != null) { final GridPane gridPane = new GridPane(); gridPane.setHgap(0); gridPane.setAlignment(Pos.TOP_LEFT); // icon final ConstellationIcon icon = IconManager.getIcon(item); final Image iconImage = icon.buildImage(); final ImageView imageView = new ImageView(iconImage); imageView.setPreserveRatio(true); imageView.setFitHeight(RECT_SIZE); final ColumnConstraints titleConstraint = new ColumnConstraints(RECT_SIZE); titleConstraint.setHalignment(HPos.CENTER); gridPane.getColumnConstraints().addAll(titleConstraint); gridPane.add(imageView, 0, 0); // dimension text if (iconImage != null) { final int width = (int) (iconImage.getWidth()); final int height = (int) (iconImage.getHeight()); final Text dimensionText = new Text(String.format("(%dx%d)", width, height)); dimensionText.setFill(Color.web("#d3d3d3")); gridPane.add(dimensionText, 0, 1); } // icon name final String displayableItem = icon.getExtendedName(); final String[] splitItem = displayableItem.split("\\."); String iconName = splitItem[splitItem.length - 1]; if (iconName.isEmpty()) { iconName = "(no icon)"; } this.setText(iconName); // tooltip final Tooltip tt = new Tooltip(item); this.setTooltip(tt); this.setGraphic(gridPane); this.setPrefHeight(RECT_SIZE + SPACING); } else { this.setText(null); this.setGraphic(null); } }
Example 18
Source File: Exercise_16_17.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a stack pane for text StackPane paneForText = new StackPane(text); paneForText.setPadding(new Insets(20, 10, 5, 10)); // Set slider properties slRed.setMin(0.0); slRed.setMax(1.0); slGreen.setMin(0.0); slGreen.setMax(1.0); slBlue.setMin(0.0); slBlue.setMax(1.0); slOpacity.setMin(0.0); slOpacity.setMax(1.0); // Create listeners slRed.valueProperty().addListener(ov -> setColor()); slGreen.valueProperty().addListener(ov -> setColor()); slBlue.valueProperty().addListener(ov -> setColor()); slOpacity.valueProperty().addListener(ov -> setColor()); slOpacity.setValue(1); // Create a grid pane for labeled sliders GridPane paneForSliders = new GridPane(); paneForSliders.setAlignment(Pos.CENTER); paneForSliders.setVgap(5); paneForSliders.setHgap(5); paneForSliders.add(new Label("Red"), 0, 0); paneForSliders.add(slRed, 1, 0); paneForSliders.add(new Label("Green"), 0, 1); paneForSliders.add(slGreen, 1, 1); paneForSliders.add(new Label("Blue"), 0, 2); paneForSliders.add(slBlue, 1, 2); paneForSliders.add(new Label("Opacity"), 0, 3); paneForSliders.add(slOpacity, 1, 3); // Place nodes in a border pane BorderPane pane = new BorderPane(); pane.setTop(paneForText); pane.setCenter(paneForSliders); // Create a scene and place it in the stage Scene scene = new Scene(pane, 250, 150); primaryStage.setTitle("Exercise_16_17"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 19
Source File: DateTimeEditorFactory.java From constellation with Apache License 2.0 | 4 votes |
@Override protected Node createEditorControls() { final GridPane controls = new GridPane(); controls.setAlignment(Pos.CENTER); controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING); noValueCheckBox = new CheckBox(NO_VALUE_LABEL); noValueCheckBox.setAlignment(Pos.CENTER); noValueCheckBox.selectedProperty().addListener((v, o, n) -> { datePicker.setDisable(noValueCheckBox.isSelected()); hourSpinner.setDisable(noValueCheckBox.isSelected()); minSpinner.setDisable(noValueCheckBox.isSelected()); secSpinner.setDisable(noValueCheckBox.isSelected()); milliSpinner.setDisable(noValueCheckBox.isSelected()); timeZoneComboBox.setDisable(noValueCheckBox.isSelected()); update(); }); final ObservableList<ZoneId> timeZones = FXCollections.observableArrayList(); ZoneId.getAvailableZoneIds().forEach(id -> { timeZones.add(ZoneId.of(id)); }); timeZoneComboBox = new ComboBox<>(); timeZoneComboBox.setItems(timeZones.sorted(zoneIdComparator)); final Callback<ListView<ZoneId>, ListCell<ZoneId>> cellFactory = (final ListView<ZoneId> p) -> new ListCell<ZoneId>() { @Override protected void updateItem(final ZoneId item, boolean empty) { super.updateItem(item, empty); if (item != null) { setText(TimeZoneUtilities.getTimeZoneAsString(currentValue == null ? null : currentValue.toLocalDateTime(), item)); } } }; final Label timeZoneComboBoxLabel = new Label("Time Zone:"); timeZoneComboBoxLabel.setId(LABEL_ID); timeZoneComboBoxLabel.setLabelFor(timeZoneComboBoxLabel); timeZoneComboBox.setCellFactory(cellFactory); timeZoneComboBox.setButtonCell(cellFactory.call(null)); timeZoneComboBox.getSelectionModel().select(TimeZoneUtilities.UTC); timeZoneComboBox.getSelectionModel().selectedItemProperty().addListener(updateTimeFromZone); final HBox timeZoneHbox = new HBox(timeZoneComboBoxLabel, timeZoneComboBox); timeZoneHbox.setSpacing(5); final HBox timeSpinnerContainer = createTimeSpinners(); controls.addRow(0, timeSpinnerContainer); controls.addRow(1, timeZoneHbox); controls.addRow(2, noValueCheckBox); return controls; }
Example 20
Source File: ShtoPunetor.java From Automekanik with GNU General Public License v3.0 | 4 votes |
public ShtoPunetor(int id, String stremri, String strmbiemri, String strkomuna, String strpozita, float strpaga, ShikoPunetoret sp){ stage.getIcons().add(new Image(getClass().getResourceAsStream("/sample/foto/icon.png"))); System.out.println(id); stage.setTitle("Shtimi i punetoreve"); stage.initModality(Modality.APPLICATION_MODAL); stage.setResizable(false); HBox btn = new HBox(5); btn.setAlignment(Pos.CENTER_RIGHT); btn.getChildren().addAll(btnOk, btnAnulo); data.setValue(LocalDate.now()); emri.setText(stremri); mbiemri.setText(strmbiemri); komuna.setText(strkomuna); pjesa.setText(strpozita); paga.setText(strpaga + ""); GridPane root = new GridPane(); root.add(new Label("Emri"), 0, 0); root.add(emri, 1, 0); root.add(new Label("Mbiemri"), 0, 1); root.add(mbiemri, 1, 1); root.add(new Label("Fjalekalimi"), 0, 2); root.add(pw, 1, 2); root.add(new Label("Komuna"), 0, 3); root.add(komuna, 1, 3); root.add(new Label("Pozita"), 0, 4); root.add(pjesa, 1, 4); root.add(new Label("Paga mujore"), 0, 5); root.add(paga, 1, 5); root.add(btn, 1, 6); pw.setPromptText("Mund te lihet i zbrazet"); btnOk.setOnAction(e -> { shtoPunetoreMethod2(id, stremri.toLowerCase() + strmbiemri.toLowerCase()); sp.mbushPunetoret(); }); btnAnulo.setOnAction(e -> stage.close()); data.setOnKeyPressed(e -> {if (e.getCode().equals(KeyCode.ENTER)){shtoPunetoreMethod2(id,stremri.toLowerCase() + strmbiemri.toLowerCase()); sp.mbushPunetoret();}}); emri.setOnKeyPressed(e -> {if (e.getCode().equals(KeyCode.ENTER)){shtoPunetoreMethod2(id,stremri.toLowerCase() + strmbiemri.toLowerCase()); sp.mbushPunetoret();}}); mbiemri.setOnKeyPressed(e -> {if (e.getCode().equals(KeyCode.ENTER)){shtoPunetoreMethod2(id,stremri.toLowerCase() + strmbiemri.toLowerCase()); sp.mbushPunetoret();}}); komuna.setOnKeyPressed(e -> {if (e.getCode().equals(KeyCode.ENTER)){shtoPunetoreMethod2(id,stremri.toLowerCase() + strmbiemri.toLowerCase()); sp.mbushPunetoret();}}); pjesa.setOnKeyPressed(e -> {if (e.getCode().equals(KeyCode.ENTER)){shtoPunetoreMethod2(id,stremri.toLowerCase() + strmbiemri.toLowerCase()); sp.mbushPunetoret();}}); paga.setOnKeyPressed(e -> {if (e.getCode().equals(KeyCode.ENTER)){shtoPunetoreMethod2(id,stremri.toLowerCase() + strmbiemri.toLowerCase()); sp.mbushPunetoret();}}); root.setVgap(7); root.setHgap(5); root.setAlignment(Pos.CENTER); Scene scene = new Scene(root, 360, 350); scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm()); stage.setScene(scene); stage.show(); }