Java 类javafx.scene.control.DialogPane 实例源码
项目:ChessBot
文件:UIUtils.java
public static void alwaysInTop(Alert alert) {
try{
DialogPane root = alert.getDialogPane();
Stage dialogStage = new Stage(StageStyle.UTILITY);
for (ButtonType buttonType : root.getButtonTypes()) {
ButtonBase button = (ButtonBase) root.lookupButton(buttonType);
button.setOnAction(evt -> {
root.setUserData(buttonType);
dialogStage.close();
});
}
root.getScene().setRoot(new Group());
Scene scene = new Scene(root);
dialogStage.setScene(scene);
dialogStage.initModality(Modality.APPLICATION_MODAL);
dialogStage.setAlwaysOnTop(true);
dialogStage.setResizable(false);
dialogStage.showAndWait();
}catch(Exception e){
}
// Optional<ButtonType> result = Optional.ofNullable((ButtonType) root.getUserData());
}
项目:dandelion
文件:MainController.java
@FXML
private void showAbout() throws IOException {
if (aboutDialog == null) {
aboutDialog = new Alert(INFORMATION);
aboutDialog.initOwner(dandelion.getPrimaryStage());
aboutDialog.initStyle(StageStyle.UTILITY);
aboutDialog.setTitle("About " + NAME);
aboutDialog.setHeaderText(NAME + ' ' + VERSION);
FXMLLoader loader = new FXMLLoader(ClassLoader.getSystemResource("fxml/about.fxml"));
Node content = loader.load();
DialogPane pane = aboutDialog.getDialogPane();
pane.getStyleClass().add("about");
pane.getStylesheets().add("css/dandelion.css");
pane.setContent(content);
}
aboutDialog.showAndWait();
}
项目:eadlsync
文件:DiffView.java
public void showDialog() {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gui/diff/diff-view.fxml"));
try {
loader.setController(diffController);
DialogPane root = loader.load();
root.getStylesheets().add(getClass().getResource("/gui/diff/diff-view.css").toExternalForm());
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Diff Viewer");
alert.setResizable(true);
alert.setDialogPane(root);
alert.initModality(Modality.WINDOW_MODAL);
Window window = alert.getDialogPane().getScene().getWindow();
window.setOnCloseRequest(event -> window.hide());
alert.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
}
项目:eadlsync
文件:ConflictManagerView.java
public boolean showDialog() {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gui/conflict/resolve-conflicts-view.fxml"));
try {
loader.setController(conflictManagerController);
DialogPane root = loader.load();
root.getStylesheets().add(getClass().getResource("/gui/conflict/resolve-conflicts-view.css").toExternalForm());
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Resolve conflicts");
alert.setResizable(true);
alert.setDialogPane(root);
alert.initModality(Modality.WINDOW_MODAL);
Window window = alert.getDialogPane().getScene().getWindow();
window.setOnCloseRequest(event -> window.hide());
alert.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
return conflictManagerController.isFinishedSuccessfully();
}
项目:JavaFX_Tutorial
文件:FXDialogController.java
/**
* Constructs and displays dialog based on the FXML at the specified URL
*
* @param url
* the location of the FXML file, relative to the
* {@code sic.nmsu.javafx} package
* @param stateInit
* a consumer used to configure the controller before FXML injection
* @return
*/
public static <R, C extends FXDialogController<R>> R show(String url, Consumer<C> stateInit) {
final Pair<Parent, C> result = FXController.get(url, stateInit);
final Parent view = result.getValue0();
final C ctrl = result.getValue1();
final Dialog<R> dialog = new Dialog<>();
dialog.titleProperty().bind(ctrl.title);
final DialogPane dialogPane = dialog.getDialogPane();
dialogPane.setContent(view);
dialogPane.getButtonTypes().add(ButtonType.CLOSE);
final Stage window = (Stage) dialogPane.getScene().getWindow();
window.getIcons().add(new Image("images/recipe_icon.png"));
final Node closeButton = dialogPane.lookupButton(ButtonType.CLOSE);
closeButton.managedProperty().bind(closeButton.visibleProperty());
closeButton.setVisible(false);
ctrl.dialog = dialog;
ctrl.dialog.showAndWait();
return ctrl.result;
}
项目:corona-ide
文件:AlertWithCheckbox.java
/**
* Creates an Alert dialog with a checkbox
*
* @param alertType
* What type of alert dialog to display
* @param label
* A text label to display next to the checkbox
* @param buttons
* A varargs array of buttons to display in the Alert
* @since 0.1.0
*/
public AlertWithCheckbox(AlertType alertType, String label, ButtonType... buttons) {
super(alertType);
// Need to force the alert to layout in order to grab the graphic, as we are replacing the dialog pane with a
// custom pane
getDialogPane().applyCss();
Node graphic = getDialogPane().getGraphic();
setDialogPane(new DialogPane() {
@Override
protected Node createDetailsButton() {
CheckBox checkbox = new CheckBox();
checkbox.setText(label);
checkbox.setOnAction(e -> checked = checkbox.isSelected());
return checkbox;
}
});
// Fool the dialog into thinking there is expandable content. An empty Group won't take up any space
getDialogPane().setExpandableContent(new Group());
getDialogPane().setExpanded(true);
// Put back the initial values
getDialogPane().setGraphic(graphic);
getDialogPane().getButtonTypes().addAll(buttons);
}
项目:BudgetMaster
文件:ModalController.java
public void init(Controller controller, Stage stage, String message)
{
labelMessage.setText(message);
stage.setOnCloseRequest((e)->{
alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle(Localization.getString(Strings.INFO_TITLE_SHUTDOWN));
alert.initModality(Modality.APPLICATION_MODAL);
alert.initOwner(controller.getStage());
alert.setHeaderText("");
alert.setContentText(Localization.getString(Strings.INFO_TEXT_SHUTDOWN));
Stage dialogStage = (Stage)alert.getDialogPane().getScene().getWindow();
dialogStage.getIcons().add(controller.getIcon());
ButtonType buttonTypeOne = new ButtonType(Localization.getString(Strings.CANCEL));
ButtonType buttonTypeTwo = new ButtonType(Localization.getString(Strings.OK));
alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeTwo);
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getButtonTypes().stream().map(dialogPane::lookupButton).forEach(button -> button.addEventHandler(KeyEvent.KEY_PRESSED, (event) -> {
if(KeyCode.ENTER.equals(event.getCode()) && event.getTarget() instanceof Button)
{
((Button)event.getTarget()).fire();
}
}));
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == buttonTypeTwo)
{
Logger.debug("Shutting down during operation due to client request...");
controller.getStage().fireEvent(new WindowEvent(controller.getStage(), WindowEvent.WINDOW_CLOSE_REQUEST));
}
e.consume();
});
}
项目:MPL
文件:OptionsDialog.java
public OptionsDialog(Window owner, MplOptions oldOptions) {
initOwner(owner);
initModality(Modality.WINDOW_MODAL);
setTitle("Options");
setResultConverter(this::convertResult);
FXMLLoader loader = new FXMLLoader(getClass().getResource("/dialog/options.fxml"));
DialogPane root;
try {
root = loader.load();
controller = requireNonNull(loader.getController(), "controller == null!");
controller.initialize(oldOptions);
} catch (IOException ex) {
throw new IllegalStateException("Unable to load FXML file", ex);
}
root.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
setDialogPane(root);
}
项目:MPL
文件:UnsavedResourcesDialog.java
public UnsavedResourcesDialog(Window owner, Collection<Path> unsavedResources) {
initOwner(owner);
initModality(Modality.WINDOW_MODAL);
setTitle("Unsaved Resources");
setResizable(true);
setResultConverter(this::convertResult);
FXMLLoader loader = new FXMLLoader(getClass().getResource("/dialog/unsaved-resources.fxml"));
DialogPane root;
try {
root = loader.load();
controller = requireNonNull(loader.getController(), "constroller == null!");
controller.initialize(unsavedResources);
} catch (IOException ex) {
throw new IllegalStateException("Unable to load FXML file", ex);
}
root.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
setDialogPane(root);
}
项目:StudyGuide
文件:ChooseCourseDialogPaneCreator.java
/**
* Create the dialog for choosing courses.
*
* @param courseList the list of courses to show in the dialog (let the user pick from them)
* @return the controller of the dialog window, enabling to display the dialog and read the selected result
*/
public ChooseCourseController create(List<Course> courseList) {
FXMLLoader fxmlLoader = this.fxmlLoader.get();
DialogPane dialogPane = null;
try (InputStream is = getClass().getResourceAsStream("ChooseCourseDialogPane.fxml")) {
dialogPane = fxmlLoader.load(is);
} catch (IOException e) {
AlertCreator.handleLoadLayoutError(fxmlLoader.getResources(), e);
}
ChooseCourseController chooseCourseController = fxmlLoader.getController();
chooseCourseController.setCourseList(courseList);
Dialog<ButtonType> dialog = new Dialog<>();
dialog.setDialogPane(dialogPane);
chooseCourseController.setDialog(dialog);
dialog.setTitle("StudyGuide");
return chooseCourseController;
}
项目:StudyGuide
文件:EnterStringDialogPaneCreator.java
/**
* Create the dialog for entering a String.
*
* @param prompt the string message to prompt the user with
* @return the controller of the dialog window, enabling to display the dialog and read the selected result
*/
public EnterStringController create(String prompt) {
FXMLLoader fxmlLoader = this.fxmlLoader.get();
DialogPane dialogPane = null;
try (InputStream is = getClass().getResourceAsStream("EnterStringDialogPane.fxml")) {
dialogPane = fxmlLoader.load(is);
} catch (IOException e) {
AlertCreator.handleLoadLayoutError(fxmlLoader.getResources(), e);
}
dialogPane.setHeaderText(prompt);
EnterStringController enterStringController = fxmlLoader.getController();
Dialog<ButtonType> dialog = new Dialog<>();
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.setDialogPane(dialogPane);
enterStringController.setDialog(dialog);
dialog.setTitle("StudyGuide");
dialog.setOnShown(event -> enterStringController.getTextField().requestFocus());
return enterStringController;
}
项目:Map-Projections
文件:ProgressBarDialog.java
public ProgressBarDialog() {
DialogPane pane = this.getDialogPane();
this.bar = new ProgressBar();
this.bar.setPrefWidth(300);
this.words = new Label();
this.words.setMinWidth(50);
this.words.setAlignment(Pos.BASELINE_RIGHT);
this.box = new HBox(5);
this.setTitle(""); // set the words on it
pane.setHeaderText("Please wait.");
pane.getButtonTypes().addAll(new ButtonType[] { ButtonType.CLOSE });
((Button) pane.lookupButton(ButtonType.CLOSE)).setText("Run in background"); // you can't close it
((Button) pane.lookupButton(ButtonType.CLOSE)).setTooltip(new Tooltip("Oh, did you want a cancel button? Well, TOO BAD. Cancel buttons are hard."));
this.resetBar();
this.setResultConverter((btn) -> { // set the return value
return null;
});
}
项目:jfx-torrent
文件:AddTrackerWindow.java
private void initComponents() {
window.setTitle(WINDOW_TITLE);
window.setResizable(true);
final DialogPane windowPane = window.getDialogPane();
windowPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
final Button okButton = (Button)windowPane.lookupButton(ButtonType.OK);
trackerInputArea.textProperty().addListener((obs, oldV, newV) -> okButton.setDisable(newV.isEmpty()));
final ScrollPane inputAreaScroll = new ScrollPane(trackerInputArea);
inputAreaScroll.setFitToHeight(true);
inputAreaScroll.setFitToWidth(true);
final TitledBorderPane titledTrackerPane = new TitledBorderPane("List of trackers to add",
inputAreaScroll, BorderStyle.COMPACT, TitledBorderPane.PRIMARY_BORDER_COLOR_STYLE);
final Pane trackerInputPane = new Pane(titledTrackerPane);
titledTrackerPane.prefWidthProperty().bind(trackerInputPane.widthProperty());
titledTrackerPane.prefHeightProperty().bind(trackerInputPane.heightProperty());
windowPane.setContent(trackerInputPane);
}
项目:AsciidocFX
文件:AlertHelper.java
public static void showDuplicateWarning(List<String> duplicatePaths, Path lib) {
Alert alert = new Alert(Alert.AlertType.WARNING);
DialogPane dialogPane = alert.getDialogPane();
ListView listView = new ListView();
listView.getStyleClass().clear();
ObservableList items = listView.getItems();
items.addAll(duplicatePaths);
listView.setEditable(false);
dialogPane.setContent(listView);
alert.setTitle("Duplicate JARs found");
alert.setHeaderText(String.format("Duplicate JARs found, it may cause unexpected behaviours.\n\n" +
"Please remove the older versions from these pair(s) manually. \n" +
"JAR files are located at %s directory.", lib));
alert.getButtonTypes().clear();
alert.getButtonTypes().addAll(ButtonType.OK);
alert.showAndWait();
}
项目:amelia
文件:AboutFormController.java
public void showAbout(){
//root.getStylesheets().add("/styles/Styles.css");
DialogPane p = new DialogPane();
p.getStylesheets().add("/styles/Styles.css");
p.setContent(root);
this.setDialogPane(p);
this.setTitle("About");
this.setResizable(false);
p.getButtonTypes().add(ButtonType.OK);
this.initModality(Modality.APPLICATION_MODAL);
this.initStyle(StageStyle.UNIFIED);
this.show();
}
项目:CSS-Editor-FX
文件:OptionsController.java
static void show(Window window) {
try {
Pair<OptionsController, DialogPane> pair = Util.renderFxml(OptionsController.class);
Dialog<Void> dialog = new Dialog<>();
dialog.initOwner(window);
dialog.setDialogPane(pair.getValue());
dialog.show();
} catch (IOException e) {
e.printStackTrace();
}
}
项目:AlertFX
文件:MsgBox.java
/**
* Applies a custom css file to the alert
* @param path The full path of the css file
*/
public void applyCss(String path){
if (dialog.isShowing()) {
throw new AlertNotEditableException("Unable to edit alert while it is being shown");
}
DialogPane dialogPane = dialog.getDialogPane();
dialogPane.getStylesheets().add(getClass().getResource(path).toExternalForm());
dialogPane.getStyleClass().add(path.replace(".css", "")); // Shouldn't have extension
}
项目:AlertFX
文件:ChoiceBox.java
/**
* Applies a custom css file to the alert
* @param path The full path of the css file
*/
public void applyCss(String path){
if (alert.isShowing()){
throw new AlertNotEditableException("Alert not editable while it is showing");
}
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(getClass().getResource(path).toExternalForm());
dialogPane.getStyleClass().add(path.replace(".css", "")); // Shouldn't have extension
}
项目:AlertFX
文件:ConfirmExit.java
/**
* Applies a custom css file to the alert
* @param path The full path of the css file
*/
public void applyCss(String path){
if (alert.isShowing()){
throw new AlertNotEditableException("Alert not editable while it is showing");
}
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(getClass().getResource(path).toExternalForm());
dialogPane.getStyleClass().add(path.replace(".css", "")); // Shouldn't have extension
}
项目:AlertFX
文件:Prompt.java
/**
* Applies a custom css file to the alert
* @param path The full path of the css file
*/
public void applyCss(String path){
if (alert.isShowing()){
throw new AlertNotEditableException("Alert not editable while it is showing");
}
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(getClass().getResource(path).toExternalForm());
dialogPane.getStyleClass().add(path.replace(".css", "")); // Shouldn't have extension
}
项目:AlertFX
文件:Warn.java
/**
* Applies a custom css file to the alert
* @param path The full path of the css file
*/
public void applyCss(String path){
if (alert.isShowing()){
throw new AlertNotEditableException("Alert not editable while it is showing");
}
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(getClass().getResource(path).toExternalForm());
dialogPane.getStyleClass().add(path.replace(".css", "")); // Shouldn't have extension
}
项目:AlertFX
文件:QuestionBox.java
/**
* Applies a custom css file to the alert
* @param path The full path of the css file
*/
public void applyCss(String path){
if (alert.isShowing()){
throw new AlertNotEditableException("Alert not editable while it is showing");
}
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(getClass().getResource(path).toExternalForm());
dialogPane.getStyleClass().add(path.replace(".css", "")); // Shouldn't have extension
}
项目:AlertFX
文件:ErrorBox.java
/**
* Applies a custom css file to the alert
* @param path The full path of the css file
*/
public void applyCss(String path){
if (alert.isShowing()){
throw new AlertNotEditableException("Alert not editable while it is showing");
}
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(getClass().getResource(path).toExternalForm());
dialogPane.getStyleClass().add(path.replace(".css", "")); // Shouldn't have extension
}
项目:jmonkeybuilder
文件:EditorUtil.java
/**
* Create a dialog for showing the exception.
*/
@FXThread
private static @NotNull Alert createErrorAlert(@NotNull final Exception e, @Nullable final String localizedMessage,
@Nullable final String stackTrace) {
final TextArea textArea = new TextArea(stackTrace);
textArea.setEditable(false);
textArea.setWrapText(true);
VBox.setMargin(textArea, new Insets(2, 5, 2, 5));
final Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setHeaderText(StringUtils.isEmpty(localizedMessage) ? e.getClass().getSimpleName() : localizedMessage);
final DialogPane dialogPane = alert.getDialogPane();
dialogPane.setExpandableContent(new VBox(textArea));
dialogPane.expandedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == Boolean.TRUE) {
alert.setWidth(800);
alert.setHeight(400);
} else {
alert.setWidth(500);
alert.setHeight(220);
}
});
return alert;
}
项目:corona-ide
文件:MainController.java
@FXML
private void handleAboutHelp(ActionEvent event) {
try {
// Load the fxml file and create a new stage for the popup dialog.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(CoronaUIApplication.class.getResource("/fxml/AboutDialog.fxml"));
DialogPane pane = (DialogPane) loader.load();
// Create the dialog Stage.
Stage dialogStage = new Stage();
dialogStage.setTitle("About Corona IDE");
dialogStage.initModality(Modality.WINDOW_MODAL);
dialogStage.setResizable(false);
dialogStage.initOwner(CoronaUIApplication.getPrimaryStage());
Scene scene = new Scene(pane);
dialogStage.setScene(scene);
dialogStage.sizeToScene();
// Set the person into the controller.
AboutDialogController controller = loader.getController();
controller.setDialogStage(dialogStage);
// Show the dialog and wait until the user closes it
dialogStage.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
}
项目:CSS-Editor-FX
文件:OptionsController.java
static void show(Window window) {
try {
Pair<OptionsController, DialogPane> pair = Util.renderFxml(OptionsController.class);
Dialog<Void> dialog = new Dialog<>();
dialog.initOwner(window);
dialog.setDialogPane(pair.getValue());
dialog.show();
} catch (IOException e) {
e.printStackTrace();
}
}
项目:BudgetMaster
文件:DatabaseImporter.java
public void importDatabase()
{
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle(Localization.getString(Strings.INFO_TITLE_DATABASE_IMPORT_DIALOG));
alert.setHeaderText("");
alert.setContentText(Localization.getString(Strings.INFO_TEXT_DATABASE_IMPORT_DIALOG));
Stage dialogStage = (Stage)alert.getDialogPane().getScene().getWindow();
dialogStage.getIcons().add(controller.getIcon());
dialogStage.initOwner(controller.getStage());
ButtonType buttonTypeDelete = new ButtonType(Localization.getString(Strings.INFO_TEXT_DATABASE_IMPORT_DIALOG_DELETE));
ButtonType buttonTypeAppend = new ButtonType(Localization.getString(Strings.INFO_TEXT_DATABASE_IMPORT_DIALOG_APPEND));
ButtonType buttonTypeCancel = new ButtonType(Localization.getString(Strings.CANCEL), ButtonData.CANCEL_CLOSE);
alert.getButtonTypes().setAll(buttonTypeDelete, buttonTypeAppend, buttonTypeCancel);
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getButtonTypes().stream().map(dialogPane::lookupButton).forEach(button -> button.addEventHandler(KeyEvent.KEY_PRESSED, (event) -> {
if(KeyCode.ENTER.equals(event.getCode()) && event.getTarget() instanceof Button)
{
((Button)event.getTarget()).fire();
}
}));
Optional<ButtonType> result = alert.showAndWait();
if(result.get() == buttonTypeDelete)
{
DatabaseDeleter deleter = new DatabaseDeleter(controller);
deleter.deleteDatabase(true);
}
else if(result.get() == buttonTypeAppend)
{
importDB();
}
}
项目:MPL
文件:FileNameDialog.java
public FileNameDialog(Window owner, String title, String description,
FileNameValidator fileNameValidator) {
initOwner(owner);
initModality(Modality.WINDOW_MODAL);
setTitle(title);
setResultConverter(this::convertResult);
FXMLLoader loader = new FXMLLoader(getClass().getResource("/dialog/file-name.fxml"));
DialogPane root;
try {
root = loader.load();
} catch (IOException ex) {
throw new IllegalStateException("Unable to load FXML file", ex);
}
controller = requireNonNull(loader.getController(), "controller == null!");
setOnShown(e -> Platform.runLater(() -> {
TextField textField = controller.getTextField();
textField.requestFocus();
textField.home();
}));
root.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
setDialogPane(root);
setHeaderText(description);
controller.getTextField().textProperty().addListener((observable, oldValue, newValue) -> {
String error = fileNameValidator.test(newValue);
if (error == null) {
setGraphic(null);
setHeaderText(description);
root.lookupButton(ButtonType.OK).setDisable(false);
} else {
setGraphic(new ImageView("/icons/message_error.png"));
setHeaderText(error);
root.lookupButton(ButtonType.OK).setDisable(true);
}
});
}
项目:VocabHunter
文件:ErrorDialogue.java
public ErrorDialogue(final String title, final Throwable e, final String... messages) {
alert = new Alert(AlertType.ERROR);
alert.setTitle(title);
alert.setHeaderText(headerText(messages));
TextArea textArea = new TextArea(exceptionText(e));
VBox expContent = new VBox();
DialogPane dialoguePane = alert.getDialogPane();
expContent.getChildren().setAll(new Label("Error details:"), textArea);
dialoguePane.setExpandableContent(expContent);
dialoguePane.expandedProperty().addListener(p -> Platform.runLater(this::resizeAlert));
dialoguePane.setId("errorDialogue");
}
项目:JFoenix
文件:JFXAlert.java
private void updateY(Stage stage, DialogPane dialogPane) {
if(dialogPane.getScene()!=null) {
final Parent root = stage.getScene().getRoot();
final Bounds screenBounds = root.localToScreen(root.getLayoutBounds());
dialogPane.getScene().getWindow().setY(screenBounds.getMinY());
}
}
项目:JFoenix
文件:JFXAlert.java
private void updateX(Stage stage, DialogPane dialogPane) {
if(dialogPane.getScene()!=null) {
final Parent root = stage.getScene().getRoot();
final Bounds screenBounds = root.localToScreen(root.getLayoutBounds());
dialogPane.getScene().getWindow().setX(screenBounds.getMinX());
}
}
项目:OTBProject
文件:GuiUtils.java
public static void setDialogPaneStyle(DialogPane dialogPane) {
URL resource = GuiApplication.class.getClassLoader().getResource("style.css");
if (resource != null) {
dialogPane.getStylesheets().add(resource.toExternalForm());
} else {
App.logger.error("Unable to get style sheet for alerts.");
}
}
项目:markdown-writer-fx
文件:OptionsDialog.java
public OptionsDialog(Window owner) {
setTitle(Messages.get("OptionsDialog.title"));
initOwner(owner);
initComponents();
tabPane.getStyleClass().add(TabPane.STYLE_CLASS_FLOATING);
DialogPane dialogPane = getDialogPane();
dialogPane.setContent(tabPane);
dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
// save options on OK clicked
dialogPane.lookupButton(ButtonType.OK).addEventHandler(ActionEvent.ACTION, e -> {
save();
e.consume();
});
Utils.fixSpaceAfterDeadKey(dialogPane.getScene());
// load options
load();
// select last tab
int tabIndex = MarkdownWriterFXApp.getState().getInt("lastOptionsTab", -1);
if (tabIndex > 0 && tabIndex < tabPane.getTabs().size())
tabPane.getSelectionModel().select(tabIndex);
// remember last selected tab
setOnHidden(e -> {
MarkdownWriterFXApp.getState().putInt("lastOptionsTab", tabPane.getSelectionModel().getSelectedIndex());
});
}
项目:markdown-writer-fx
文件:LinkDialog.java
public LinkDialog(Window owner, Path basePath) {
setTitle(Messages.get("LinkDialog.title"));
initOwner(owner);
setResizable(true);
initComponents();
linkBrowseDirectoyButton.setBasePath(basePath);
linkBrowseDirectoyButton.urlProperty().bindBidirectional(urlField.escapedTextProperty());
linkBrowseFileButton.setBasePath(basePath);
linkBrowseFileButton.urlProperty().bindBidirectional(urlField.escapedTextProperty());
DialogPane dialogPane = getDialogPane();
dialogPane.setContent(pane);
dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
dialogPane.lookupButton(ButtonType.OK).disableProperty().bind(
urlField.escapedTextProperty().isEmpty());
Utils.fixSpaceAfterDeadKey(dialogPane.getScene());
link.bind(Bindings.when(titleField.escapedTextProperty().isNotEmpty())
.then(Bindings.format("[%s](%s \"%s\")", textField.escapedTextProperty(), urlField.escapedTextProperty(), titleField.escapedTextProperty()))
.otherwise(Bindings.when(textField.escapedTextProperty().isNotEmpty())
.then(Bindings.format("[%s](%s)", textField.escapedTextProperty(), urlField.escapedTextProperty()))
.otherwise(Bindings.format("<%s>", urlField.escapedTextProperty()))));
previewField.textProperty().bind(link);
setResultConverter(dialogButton -> {
return (dialogButton == ButtonType.OK) ? link.get() : null;
});
Platform.runLater(() -> {
urlField.requestFocus();
if (urlField.getText().startsWith("http://"))
urlField.selectRange("http://".length(), urlField.getLength());
});
}
项目:markdown-writer-fx
文件:ImageDialog.java
public ImageDialog(Window owner, Path basePath) {
setTitle(Messages.get("ImageDialog.title"));
initOwner(owner);
setResizable(true);
initComponents();
linkBrowseFileButton.setBasePath(basePath);
linkBrowseFileButton.addExtensionFilter(new ExtensionFilter(Messages.get("ImageDialog.chooser.imagesFilter"), "*.png", "*.gif", "*.jpg", "*.svg"));
linkBrowseFileButton.urlProperty().bindBidirectional(urlField.escapedTextProperty());
DialogPane dialogPane = getDialogPane();
dialogPane.setContent(pane);
dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
dialogPane.lookupButton(ButtonType.OK).disableProperty().bind(
urlField.escapedTextProperty().isEmpty()
.or(textField.escapedTextProperty().isEmpty()));
Utils.fixSpaceAfterDeadKey(dialogPane.getScene());
image.bind(Bindings.when(titleField.escapedTextProperty().isNotEmpty())
.then(Bindings.format("", textField.escapedTextProperty(), urlField.escapedTextProperty(), titleField.escapedTextProperty()))
.otherwise(Bindings.format("", textField.escapedTextProperty(), urlField.escapedTextProperty())));
previewField.textProperty().bind(image);
setResultConverter(dialogButton -> {
return (dialogButton == ButtonType.OK) ? image.get() : null;
});
Platform.runLater(() -> {
urlField.requestFocus();
if (urlField.getText().startsWith("http://"))
urlField.selectRange("http://".length(), urlField.getLength());
});
}
项目:aic-praise
文件:FXUtil.java
public static void exception(Throwable throwable) {
System.err.println("Exception being directed to FXUtil.exception, which is not showing anything at this point because it is not being invoked by the JavaFX thread: " + throwable);
Dialog<ButtonType> dialog = new Dialog<ButtonType>();
dialog.setTitle("Program exception");
final DialogPane dialogPane = dialog.getDialogPane();
dialogPane.setContentText("Details of the problem:");
dialogPane.getButtonTypes().addAll(ButtonType.OK);
dialogPane.setContentText(throwable.getMessage());
dialog.initModality(Modality.APPLICATION_MODAL);
Label label = new Label("Exception stacktrace:");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
throwable.printStackTrace(pw);
pw.close();
TextArea textArea = new TextArea(sw.toString());
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane root = new GridPane();
root.setVisible(false);
root.setMaxWidth(Double.MAX_VALUE);
root.add(label, 0, 0);
root.add(textArea, 0, 1);
dialogPane.setExpandableContent(root);
dialog.showAndWait();
}
项目:org.csstudio.display.builder
文件:PasswordDialog.java
/** @param title Title, message
* @param correct_password Password to check
*/
public PasswordDialog(final String title, final String correct_password)
{
this.correct_password = correct_password;
final DialogPane pane = getDialogPane();
pass_entry.setPromptText(Messages.Password_Prompt);
pass_entry.setMaxWidth(Double.MAX_VALUE);
getDialogPane().setContent(pass_entry);
setTitle(Messages.Password);
setHeaderText(title);
pane.getStyleClass().add("text-input-dialog");
pane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
// Check password in dialog?
if (correct_password != null && correct_password.length() > 0)
{
final Button okButton = (Button) pane.lookupButton(ButtonType.OK);
okButton.addEventFilter(ActionEvent.ACTION, event ->
{
if (! checkPassword())
event.consume();
});
}
setResultConverter((button) ->
{
return button.getButtonData() == ButtonData.OK_DONE ? pass_entry.getText() : null;
});
Platform.runLater(() -> pass_entry.requestFocus());
}
项目:mcanalytics
文件:FXMLDialog.java
public FXMLDialog(String fxmlFile) {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(fxmlFile));
DialogPane pane = new DialogPane();
fxmlLoader.setRoot(pane);
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch(IOException exception) {
throw new RuntimeException(exception);
}
setDialogPane(pane);
}
项目:javafx-dpi-scaling
文件:AdjusterTest.java
@Test
public void testGetDialogPaneAdjuster() {
Adjuster adjuster = Adjuster.getAdjuster(DialogPane.class);
assertThat(adjuster, is(instanceOf(PaneAdjuster.class)));
assertThat(adjuster.getNodeClass(), is(sameInstance(Pane.class)));
}
项目:ownNoteEditor
文件:TestOneNoteLookAndFeel.java
private void testAlert(final String headerText, final ButtonBar.ButtonData buttonToPress) {
final Label label = (Label) find(headerText);
final DialogPane dialogPane = (DialogPane) (((GridPane)label.getParent()).getParent());
assertNotNull("Dialogpane", dialogPane);
// now find the button and press it
// https://stackoverflow.com/questions/30755370/javafx-close-alert-box-or-any-dialog-box-programatically
interact(() -> {
Button button = null;
for ( ButtonType bt : dialogPane.getButtonTypes() )
{
if ( buttonToPress.equals(bt.getButtonData()) )
{
button = (Button) dialogPane.lookupButton( bt );
button.fire();
break;
}
}
// we should have found the button...
assertNotNull(button);
});
interact(() -> {
myStage.toFront();
});
}