本文整理汇总了Java中javafx.scene.control.DialogPane类的典型用法代码示例。如果您正苦于以下问题:Java DialogPane类的具体用法?Java DialogPane怎么用?Java DialogPane使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DialogPane类属于javafx.scene.control包,在下文中一共展示了DialogPane类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showDialog
import javafx.scene.control.DialogPane; //导入依赖的package包/类
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();
}
}
示例2: alwaysInTop
import javafx.scene.control.DialogPane; //导入依赖的package包/类
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());
}
示例3: showAbout
import javafx.scene.control.DialogPane; //导入依赖的package包/类
@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();
}
示例4: showDialog
import javafx.scene.control.DialogPane; //导入依赖的package包/类
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();
}
示例5: show
import javafx.scene.control.DialogPane; //导入依赖的package包/类
/**
* 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;
}
示例6: AlertWithCheckbox
import javafx.scene.control.DialogPane; //导入依赖的package包/类
/**
* 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);
}
示例7: init
import javafx.scene.control.DialogPane; //导入依赖的package包/类
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();
});
}
示例8: OptionsDialog
import javafx.scene.control.DialogPane; //导入依赖的package包/类
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);
}
示例9: UnsavedResourcesDialog
import javafx.scene.control.DialogPane; //导入依赖的package包/类
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);
}
示例10: create
import javafx.scene.control.DialogPane; //导入依赖的package包/类
/**
* 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;
}
示例11: create
import javafx.scene.control.DialogPane; //导入依赖的package包/类
/**
* 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;
}
示例12: ProgressBarDialog
import javafx.scene.control.DialogPane; //导入依赖的package包/类
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;
});
}
示例13: initComponents
import javafx.scene.control.DialogPane; //导入依赖的package包/类
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);
}
示例14: showDuplicateWarning
import javafx.scene.control.DialogPane; //导入依赖的package包/类
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();
}
示例15: showAbout
import javafx.scene.control.DialogPane; //导入依赖的package包/类
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();
}