Java Code Examples for javafx.scene.control.Dialog#setResizable()
The following examples show how to use
javafx.scene.control.Dialog#setResizable() .
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: SaveLayoutMenuItem.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private void positionDialog(final Dialog<?> dialog) { final List<Stage> stages = DockStage.getDockStages(); DialogHelper.positionDialog(dialog, stages.get(0).getScene().getRoot(), -100, -100); dialog.setResizable(true); dialog.getDialogPane().setMinSize(280, 160); }
Example 2
Source File: PacketHex.java From trex-stateless-gui with Apache License 2.0 | 5 votes |
/** * Show dialog * * @param selectedText * @return */ private String showDialog(String selectedText) { Dialog dialog = new Dialog(); dialog.setTitle("Edit Hex"); dialog.setResizable(false); TextField text1 = new TextField(); text1.addEventFilter(KeyEvent.KEY_TYPED, hex_Validation(2)); text1.setText(selectedText); StackPane dialogPane = new StackPane(); dialogPane.setPrefSize(150, 50); dialogPane.getChildren().add(text1); dialog.getDialogPane().setContent(dialogPane); ButtonType buttonTypeOk = new ButtonType("Save", ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().add(buttonTypeOk); dialog.setResultConverter(new Callback<ButtonType, String>() { @Override public String call(ButtonType b) { if (b == buttonTypeOk) { switch (text1.getText().length()) { case 0: return null; case 1: return "0".concat(text1.getText()); default: return text1.getText(); } } return null; } }); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { return result.get(); } return null; }
Example 3
Source File: ProjectDirectoryNotSpecifiedDialog.java From paintera with GNU General Public License v2.0 | 4 votes |
public Optional<String> showDialog(final String contentText) throws ProjectDirectoryNotSpecified { if (this.defaultToTempDirectory) { return Optional.of(tmpDir()); } final StringProperty projectDirectory = new SimpleStringProperty(null); final ButtonType specifyProject = new ButtonType("Specify Project", ButtonData.OTHER); final ButtonType noProject = new ButtonType("No Project", ButtonData.OK_DONE); final Dialog<String> dialog = new Dialog<>(); dialog.setResultConverter(bt -> { return ButtonType.CANCEL.equals(bt) ? null : noProject.equals(bt) ? tmpDir() : projectDirectory.get(); }); dialog.getDialogPane().getButtonTypes().setAll(specifyProject, noProject, ButtonType.CANCEL); dialog.setTitle("Paintera"); dialog.setHeaderText("Specify Project Directory"); dialog.setContentText(contentText); final Node lookupProjectButton = dialog.getDialogPane().lookupButton(specifyProject); if (lookupProjectButton instanceof Button) { ((Button) lookupProjectButton).setTooltip(new Tooltip("Look up project directory.")); } Optional .ofNullable(dialog.getDialogPane().lookupButton(noProject)) .filter(b -> b instanceof Button) .map(b -> (Button) b) .ifPresent(b -> b.setTooltip(new Tooltip("Create temporary project in /tmp."))); Optional .ofNullable(dialog.getDialogPane().lookupButton(ButtonType.CANCEL)) .filter(b -> b instanceof Button) .map(b -> (Button) b) .ifPresent(b -> b.setTooltip(new Tooltip("Do not start Paintera."))); lookupProjectButton.addEventFilter(ActionEvent.ACTION, event -> { final DirectoryChooser chooser = new DirectoryChooser(); final Optional<String> d = Optional.ofNullable(chooser.showDialog(dialog.getDialogPane().getScene() .getWindow())).map( File::getAbsolutePath); if (d.isPresent()) { projectDirectory.set(d.get()); } else { // consume on cancel, so that parent dialog does not get closed. event.consume(); } }); dialog.setResizable(true); final Optional<String> returnVal = dialog.showAndWait(); if (!returnVal.isPresent()) { throw new ProjectDirectoryNotSpecified(); } return returnVal; }
Example 4
Source File: DeleteLayoutsMenuItem.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private void positionDialog(final Dialog<?> dialog) { final List<Stage> stages = DockStage.getDockStages(); DialogHelper.positionDialog(dialog, stages.get(0).getScene().getRoot(), -300, -400); dialog.setResizable(true); }