List of usage examples for javafx.geometry Insets Insets
public Insets(@NamedArg("top") double top, @NamedArg("right") double right, @NamedArg("bottom") double bottom, @NamedArg("left") double left)
From source file:io.bitsquare.gui.components.paymentmethods.OKPayForm.java
private void addCurrenciesGrid(boolean isEditable) { Label label = addLabel(gridPane, ++gridRow, "Supported currencies:", 0); GridPane.setValignment(label, VPos.TOP); FlowPane flowPane = new FlowPane(); flowPane.setPadding(new Insets(10, 10, 10, 10)); flowPane.setVgap(10);//w ww .j ava2s. c om flowPane.setHgap(10); if (isEditable) flowPane.setId("flow-pane-checkboxes-bg"); else flowPane.setId("flow-pane-checkboxes-non-editable-bg"); CurrencyUtil.getAllOKPayCurrencies().stream().forEach(e -> { CheckBox checkBox = new CheckBox(e.getCode()); checkBox.setMouseTransparent(!isEditable); checkBox.setSelected(okPayAccount.getTradeCurrencies().contains(e)); checkBox.setMinWidth(60); checkBox.setMaxWidth(checkBox.getMinWidth()); checkBox.setTooltip(new Tooltip(e.getName())); checkBox.setOnAction(event -> { if (checkBox.isSelected()) okPayAccount.addCurrency(e); else okPayAccount.removeCurrency(e); updateAllInputsValid(); }); flowPane.getChildren().add(checkBox); }); GridPane.setRowIndex(flowPane, gridRow); GridPane.setColumnIndex(flowPane, 1); gridPane.getChildren().add(flowPane); }
From source file:MediaControl.java
public MediaControl(final MediaPlayer mp) { this.mp = mp; setStyle("-fx-background-color: #bfc2c7;"); mediaView = new MediaView(mp); Pane mvPane = new Pane() { };/*from w w w .j a v a2 s . co m*/ mvPane.getChildren().add(mediaView); mvPane.setStyle("-fx-background-color: black;"); setCenter(mvPane); mediaBar = new HBox(); mediaBar.setAlignment(Pos.CENTER); mediaBar.setPadding(new Insets(5, 10, 5, 10)); BorderPane.setAlignment(mediaBar, Pos.CENTER); final Button playButton = new Button(">"); playButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { Status status = mp.getStatus(); if (status == Status.UNKNOWN || status == Status.HALTED) { // don't do anything in these states return; } if (status == Status.PAUSED || status == Status.READY || status == Status.STOPPED) { // rewind the movie if we're sitting at the end if (atEndOfMedia) { mp.seek(mp.getStartTime()); atEndOfMedia = false; } mp.play(); } else { mp.pause(); } } }); mp.currentTimeProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { updateValues(); } }); mp.setOnPlaying(new Runnable() { public void run() { if (stopRequested) { mp.pause(); stopRequested = false; } else { playButton.setText("||"); } } }); mp.setOnPaused(new Runnable() { public void run() { System.out.println("onPaused"); playButton.setText(">"); } }); mp.setOnReady(new Runnable() { public void run() { duration = mp.getMedia().getDuration(); updateValues(); } }); mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1); mp.setOnEndOfMedia(new Runnable() { public void run() { if (!repeat) { playButton.setText(">"); stopRequested = true; atEndOfMedia = true; } } }); mediaBar.getChildren().add(playButton); // Add spacer Label spacer = new Label(" "); mediaBar.getChildren().add(spacer); // Add Time label Label timeLabel = new Label("Time: "); mediaBar.getChildren().add(timeLabel); // Add time slider timeSlider = new Slider(); HBox.setHgrow(timeSlider, Priority.ALWAYS); timeSlider.setMinWidth(50); timeSlider.setMaxWidth(Double.MAX_VALUE); timeSlider.valueProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { if (timeSlider.isValueChanging()) { // multiply duration by percentage calculated by slider position mp.seek(duration.multiply(timeSlider.getValue() / 100.0)); } } }); mediaBar.getChildren().add(timeSlider); // Add Play label playTime = new Label(); playTime.setPrefWidth(130); playTime.setMinWidth(50); mediaBar.getChildren().add(playTime); // Add the volume label Label volumeLabel = new Label("Vol: "); mediaBar.getChildren().add(volumeLabel); // Add Volume slider volumeSlider = new Slider(); volumeSlider.setPrefWidth(70); volumeSlider.setMaxWidth(Region.USE_PREF_SIZE); volumeSlider.setMinWidth(30); volumeSlider.valueProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { if (volumeSlider.isValueChanging()) { mp.setVolume(volumeSlider.getValue() / 100.0); } } }); mediaBar.getChildren().add(volumeSlider); setBottom(mediaBar); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); scene.setFill(Color.ALICEBLUE); stage.setScene(scene);/*www.ja v a 2s . c o m*/ stage.show(); stage.setTitle("ChoiceBox Sample"); stage.setWidth(300); stage.setHeight(200); label.setStyle("-fx-font: 25 arial;"); label.setLayoutX(40); rect.setArcHeight(8); rect.setArcWidth(8); rect.setStroke(Color.BLUE); rect.setStrokeWidth(3); rect.setFill(Color.WHITE); final String[] greetings = new String[] { "Hello", "Hola", "??????", "?", "?????" }; final ChoiceBox cb = new ChoiceBox( FXCollections.observableArrayList("English", "Espaol", "???????", "????", "???")); cb.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue ov, Number value, Number new_value) { label.setText(greetings[new_value.intValue()]); } }); cb.setTooltip(new Tooltip("Select the language")); cb.setValue("English"); HBox hb = new HBox(); hb.getChildren().addAll(cb, label); hb.setSpacing(30); hb.setAlignment(Pos.CENTER); hb.setPadding(new Insets(10, 0, 0, 10)); ((Group) scene.getRoot()).getChildren().add(hb); }
From source file:de.perdian.apps.tagtiger.fx.handlers.batchupdate.UpdateFileNamesFromTagsActionEventHandler.java
@Override protected BatchUpdateDialog createDialog() { ObservableList<UpdateFileNamesFromTagsItem> items = FXCollections.observableArrayList( this.getOtherFiles().stream().map(UpdateFileNamesFromTagsItem::new).collect(Collectors.toList())); StringProperty patternFieldProperty = new SimpleStringProperty(); List<String> patternItems = Arrays.asList("${track} ${title}"); ComboBox<String> patternBox = new ComboBox<>(FXCollections.observableArrayList(patternItems)); patternBox.setEditable(true);/*from w ww .j a va2 s .co m*/ patternBox.setMaxWidth(Double.MAX_VALUE); Bindings.bindBidirectional(patternFieldProperty, patternBox.editorProperty().get().textProperty()); HBox.setHgrow(patternBox, Priority.ALWAYS); Button executeButton = new Button(this.getLocalization().executeRename(), new ImageView(new Image(UpdateFileNamesFromTagsActionEventHandler.class.getClassLoader() .getResourceAsStream("icons/16/save.png")))); executeButton.setDisable(true); patternFieldProperty .addListener((o, oldValue, newValue) -> executeButton.setDisable(newValue.length() <= 0)); HBox patternFieldPane = new HBox(10, patternBox, executeButton); patternFieldPane.setPadding(new Insets(5, 5, 5, 5)); TitledPane patternFieldTitlePane = new TitledPane(this.getLocalization().fileNamePattern(), patternFieldPane); patternFieldTitlePane.setCollapsible(false); TableView<?> newFileNamesPane = this.createNewFileNamesPane(items); newFileNamesPane.setPrefHeight(400); VBox.setVgrow(newFileNamesPane, Priority.ALWAYS); VBox actionPane = new VBox(10, patternFieldTitlePane, newFileNamesPane); // Create the dialog and finish BatchUpdateDialog dialog = new BatchUpdateDialog(); dialog.setDialogPrefWidth(800); dialog.setDialogTitle(this.getLocalization().updateFileNames()); dialog.setActionPane(actionPane); dialog.setLegendPane(this.createLegendPane()); // Add listeners this.getOtherFiles().addListener( new WeakListChangeListener<>((Change<? extends TaggableFile> change) -> items.setAll(change .getList().stream().map(UpdateFileNamesFromTagsItem::new).collect(Collectors.toList())))); patternFieldProperty.addListener((o, oldValue, newValue) -> this.computeNewFileNames(items, newValue)); executeButton.setOnAction(event -> { this.updateNewFileNames(items); ((Stage) executeButton.getScene().getWindow()).close(); }); return dialog; }
From source file:gov.va.isaac.gui.util.ErrorMarkerUtils.java
/** * Setup an 'EXCLAMATION' error marker on the component. Automatically displays anytime that the reasonWhyControlInvalid value * is false. Hides when the isControlCurrentlyValid is true. * @param stackPane - optional - created if necessary *//*from ww w .jav a 2 s . c om*/ public static StackPane setupErrorMarker(Node initialNode, StackPane stackPane, ValidBooleanBinding isNodeCurrentlyValid) { ImageView exclamation = Images.EXCLAMATION.createImageView(); if (stackPane == null) { stackPane = new StackPane(); } exclamation.visibleProperty().bind(isNodeCurrentlyValid.not()); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(isNodeCurrentlyValid.getReasonWhyInvalid()); Tooltip.install(exclamation, tooltip); tooltip.setAutoHide(true); exclamation.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { tooltip.show(exclamation, event.getScreenX(), event.getScreenY()); } }); stackPane.setMaxWidth(Double.MAX_VALUE); stackPane.getChildren().add(initialNode); StackPane.setAlignment(initialNode, Pos.CENTER_LEFT); stackPane.getChildren().add(exclamation); StackPane.setAlignment(exclamation, Pos.CENTER_RIGHT); double insetFromRight; if (initialNode instanceof ComboBox) { insetFromRight = 30.0; } else if (initialNode instanceof ChoiceBox) { insetFromRight = 25.0; } else { insetFromRight = 5.0; } StackPane.setMargin(exclamation, new Insets(0.0, insetFromRight, 0.0, 0.0)); return stackPane; }
From source file:Main.java
@Override public void start(Stage stage) { Callback<TableColumn<Person, String>, TableCell<Person, String>> cellFactory = ( TableColumn<Person, String> p) -> new EditingCell(); Scene scene = new Scene(new Group()); stage.setWidth(450);/*ww w . j av a 2s. c om*/ stage.setHeight(550); table.setEditable(true); TableColumn<Person, String> firstNameCol = new TableColumn<>("First Name"); firstNameCol.setMinWidth(100); firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); firstNameCol.setCellFactory(cellFactory); firstNameCol.setOnEditCommit((CellEditEvent<Person, String> t) -> { ((Person) t.getTableView().getItems().get(t.getTablePosition().getRow())).setFirstName(t.getNewValue()); }); TableColumn<Person, String> lastNameCol = new TableColumn<>("Last Name"); lastNameCol.setMinWidth(100); lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); table.setItems(data); table.getColumns().addAll(firstNameCol, lastNameCol); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(table); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); }
From source file:org.pdfsam.ui.selection.single.SingleSelectionPane.java
public SingleSelectionPane(String ownerModule) { super(5);/*from w w w . j av a 2 s . c om*/ this.ownerModule = defaultString(ownerModule); field.enforceValidation(true, false); field.getTextField().setPromptText( DefaultI18nContext.getInstance().i18n("Select or drag and drop the PDF you want to split")); encryptionIndicator = new LoadingStatusIndicator(this, this.ownerModule); field.setGraphic(encryptionIndicator); HBox.setMargin(encryptionIndicator, new Insets(0, 0, 0, 2)); HBox topRow = new HBox(5, field); HBox.setHgrow(field, Priority.ALWAYS); topRow.setAlignment(Pos.CENTER_LEFT); getChildren().addAll(topRow, pages); field.getTextField().setEditable(false); field.getTextField().validProperty().addListener((o, oldVal, newVal) -> { if (newVal == ValidationState.VALID) { if (descriptor != null) { descriptor.invalidate(); } PdfLoadRequestEvent loadEvent = new PdfLoadRequestEvent(getOwnerModule()); descriptor = PdfDocumentDescriptor .newDescriptorNoPassword(new File(field.getTextField().getText())); descriptor.loadedProperty().addListener(new WeakChangeListener<>(onDescriptorLoaded)); field.getTextField().getContextMenu().getItems().forEach(i -> i.setDisable(false)); loadEvent.add(descriptor); eventStudio().broadcast(loadEvent); } }); initContextMenu(); }
From source file:uk.co.everywheremusic.viewcontroller.SetupScene.java
private void startSetupWindow(Stage primaryStage) { try {/*from w w w. ja v a2 s. c om*/ installFolder = new File(".").getCanonicalPath() + Globals.INSTALL_EXT; } catch (IOException ex) { Logger.getLogger(SetupScene.class.getName()).log(Level.SEVERE, null, ex); installFolder = System.getProperty("user.dir") + Globals.INSTALL_EXT; } primaryStage.setTitle(Globals.APP_NAME); grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); column1 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column1.setHgrow(Priority.ALWAYS); column2 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column2.setHgrow(Priority.ALWAYS); column3 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column3.setHgrow(Priority.ALWAYS); column4 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column4.setHgrow(Priority.ALWAYS); grid.getColumnConstraints().addAll(column1, column2, column3, column4); sceneTitle = new Label(Globals.SETUP_FRAME_TITLE); sceneTitle.setId(Globals.CSS_TITLE_ID); sceneTitle.setPrefWidth(Double.MAX_VALUE); sceneTitle.setAlignment(Pos.CENTER); ImageView imageView = null; try { imageView = new ImageView(); String img = new File(Globals.IC_LOGO).toURI().toURL().toString(); imgLogo = new Image(img); imageView.setImage(imgLogo); } catch (MalformedURLException ex) { Logger.getLogger(ServerScene.class.getName()).log(Level.SEVERE, null, ex); } GridPane titlePane = new GridPane(); ColumnConstraints c1 = new ColumnConstraints(50); ColumnConstraints c2 = new ColumnConstraints(400); titlePane.getColumnConstraints().addAll(c1, c2); titlePane.add(imageView, 0, 0); titlePane.add(sceneTitle, 1, 0); titlePane.setAlignment(Pos.CENTER); grid.add(titlePane, 0, 0, 4, 1); lblFolder = new Label(Globals.SETUP_LBL_MUSIC_FOLDER); grid.add(lblFolder, 0, 2, 3, 1); txtFolder = new TextField(); txtFolder.setText("/home/kyle/Music/Test music"); grid.add(txtFolder, 0, 3, 3, 1); btnFolder = new Button(Globals.SETUP_BTN_MUSIC_FOLDER); btnFolder.setPrefWidth(Double.MAX_VALUE); grid.add(btnFolder, 3, 3); final DirectoryChooser dirChooser = new DirectoryChooser(); btnFolder.setOnAction((ActionEvent event) -> { File dir = dirChooser.showDialog(primaryStage); if (dir != null) { txtFolder.setText(dir.getAbsolutePath()); } }); lblPassword = new Label("Choose a password:"); grid.add(lblPassword, 0, 4, 2, 1); lblConfirmPassword = new Label("Confirm your password:"); grid.add(lblConfirmPassword, 2, 4, 2, 1); txtPassword = new PasswordField(); grid.add(txtPassword, 0, 5, 2, 1); txtConfirmPassword = new PasswordField(); grid.add(txtConfirmPassword, 2, 5, 1, 1); textArea = new TextArea(); textArea.setPrefHeight(Double.MAX_VALUE); textArea.setDisable(true); textArea.setWrapText(true); grid.add(textArea, 0, 7, 4, 2); StackPane progressPane = new StackPane(); lblProgress = new Label(Globals.SETUP_LBL_PERCENT); lblProgress.setId(Globals.CSS_PROGBAR_LBL_ID); lblProgress.setVisible(false); progressBar = new ProgressBar(0); progressBar.setPrefWidth(Double.MAX_VALUE); progressBar.setVisible(false); progressPane.getChildren().addAll(progressBar, lblProgress); progressPane.setAlignment(Pos.CENTER_RIGHT); grid.add(progressPane, 0, 11, 3, 1); StackPane buttonPane = new StackPane(); btnInstall = new Button(Globals.SETUP_BTN_INSTALL); btnInstall.setPrefWidth(Double.MAX_VALUE); btnDone = new Button(Globals.SETUP_BTN_DONE); btnDone.setPrefWidth(Double.MAX_VALUE); btnDone.setVisible(false); buttonPane.getChildren().addAll(btnInstall, btnDone); grid.add(buttonPane, 3, 11); btnInstall.setOnAction((ActionEvent event) -> { boolean valid = validateForm(); if (valid) { lblFolder.setDisable(true); txtFolder.setDisable(true); btnFolder.setDisable(true); lblPassword.setDisable(true); txtPassword.setDisable(true); lblConfirmPassword.setDisable(true); txtConfirmPassword.setDisable(true); textArea.setDisable(false); lblProgress.setVisible(true); progressBar.setVisible(true); btnInstall.setDisable(true); musicFolder = txtFolder.getText(); password = txtPassword.getText(); setupWorker = createSetupWorker(); progressBar.progressProperty().unbind(); progressBar.progressProperty().bind(setupWorker.progressProperty()); setupWorker.messageProperty().addListener( (ObservableValue<? extends String> observable, String oldValue, String newValue) -> { String[] values = newValue.split("\\|"); lblProgress.setText(values[0] + "%"); textArea.appendText(values[1] + "\n"); if (values[1].equals(Globals.SETUP_MSG_DONE)) { btnInstall.setVisible(false); btnDone.setVisible(true); } }); new Thread(setupWorker).start(); } }); btnDone.setOnAction((ActionEvent event) -> { primaryStage.hide(); new ServerScene(installFolder, musicFolder).showWindow(new Stage()); }); try { String imgUrl = new File(Globals.IC_LOGO).toURI().toURL().toString(); javafx.scene.image.Image i = new javafx.scene.image.Image(imgUrl); primaryStage.getIcons().add(i); } catch (MalformedURLException ex) { Logger.getLogger(ServerScene.class.getName()).log(Level.SEVERE, null, ex); } scene = new Scene(grid, 600, 400); primaryStage.setScene(scene); scene.getStylesheets().add(SetupScene.class.getResource(Globals.CSS_FILE).toExternalForm()); // grid.setGridLinesVisible(true); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Table View Sample"); stage.setWidth(300);/*from w w w. ja va 2s . co m*/ stage.setHeight(500); final Label label = new Label("Student IDs"); label.setFont(new Font("Arial", 20)); TableColumn<Map, String> firstDataColumn = new TableColumn<>("Class A"); TableColumn<Map, String> secondDataColumn = new TableColumn<>("Class B"); firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey)); firstDataColumn.setMinWidth(130); secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey)); secondDataColumn.setMinWidth(130); TableView tableView = new TableView<>(generateDataInMap()); tableView.setEditable(true); tableView.getSelectionModel().setCellSelectionEnabled(true); tableView.getColumns().setAll(firstDataColumn, secondDataColumn); Callback<TableColumn<Map, String>, TableCell<Map, String>> cellFactoryForMap = ( TableColumn<Map, String> p) -> new TextFieldTableCell(new StringConverter() { @Override public String toString(Object t) { return t.toString(); } @Override public Object fromString(String string) { return string; } }); firstDataColumn.setCellFactory(cellFactoryForMap); secondDataColumn.setCellFactory(cellFactoryForMap); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(label, tableView); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); }
From source file:jlotoprint.MainViewController.java
public static void loadAboutWindow() { //setup/*from www . j a v a2 s. c o m*/ Dialog dialog = new Dialog<>(); dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE); dialog.setTitle("About JLotoPanel"); dialog.setHeaderText("JLotoPanel v1.0"); ImageView icon = new ImageView("file:resources/icon.png"); icon.setSmooth(true); icon.setFitHeight(48.0); icon.setFitWidth(48.0); dialog.setGraphic(icon); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(JLotoPrint.stage.getScene().getWindow()); //content GridPane grid = new GridPane(); grid.setPadding(new Insets(10, 10, 0, 10)); //text TextArea textArea = new TextArea("For more info, please visit: https://github.com/mbppower/JLotoPanel"); textArea.setWrapText(true); grid.add(textArea, 0, 0); dialog.getDialogPane().setContent(grid); dialog.showAndWait(); }