当前位置: 首页>>代码示例>>Java>>正文


Java Dialog类代码示例

本文整理汇总了Java中javafx.scene.control.Dialog的典型用法代码示例。如果您正苦于以下问题:Java Dialog类的具体用法?Java Dialog怎么用?Java Dialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Dialog类属于javafx.scene.control包,在下文中一共展示了Dialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: eval

import javafx.scene.control.Dialog; //导入依赖的package包/类
/**
 * Creates the javafx Dialog via the producer, shows it and returns the evaluated result as Optional.
 *
 * @param <T>            type of the result
 * @param <P>            result type of the preProducer
 * @param <V>
 * @param dialogProducer the javafx Dialog producer, must not be null and must not return null.
 * @return the result of the evaluation, never null.
 */
public <T, V extends Dialog<T>> Optional<T> eval(Callable<V> dialogProducer) {
    try {
        Objects.requireNonNull(dialogProducer, "The dialogProducer is null, not allowed");

        V dialog = FxSaft.dispatch(dialogProducer);
        Params p = buildParameterBackedUpByDefaults(dialog.getClass());
        if ( isOnceModeAndActiveWithSideeffect(p.key()) ) return Optional.empty();
        dialog.getDialogPane().getScene().setRoot(new BorderPane()); // Remove the DialogPane form the Scene, otherwise an Exception is thrown
        Window window = constructAndShow(SwingCore.wrap(dialog.getDialogPane()), p, Dialog.class); // Constructing the JFrame/JDialog, setting the parameters and makeing it visible
        dialog.getDialogPane().getButtonTypes().stream().map(t -> dialog.getDialogPane().lookupButton(t)).forEach(b -> { // Add Closing behavior on all buttons.
            ((Button)b).setOnAction(e -> {
                L.debug("Close on Dialog called");
                Ui.closeWindowOf(window);
            });
        });
        wait(window);
        return Optional.ofNullable(dialog.getResult());

    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:gg-net,项目名称:dwoss,代码行数:32,代码来源:DialogBuilder.java

示例2: setup

import javafx.scene.control.Dialog; //导入依赖的package包/类
private void setup() {
	ProjectConfig config = ProjectConfig.getLast();

	Dialog<ProjectConfig> dialog = new Dialog<>();
	//dialog.initModality(Modality.APPLICATION_MODAL);
	dialog.setResizable(true);
	dialog.setTitle("UID Setup");
	dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

	Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK);

	UidSetupPane setupPane = new UidSetupPane(config, dialog.getOwner(), okButton);
	dialog.getDialogPane().setContent(setupPane);
	dialog.setResultConverter(button -> button == ButtonType.OK ? config : null);

	dialog.showAndWait().ifPresent(newConfig -> {
		setupPane.updateConfig();

		if (!newConfig.isValid()) return;

		newConfig.saveAsLast();
	});
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:24,代码来源:UidMenu.java

示例3: centerDialogOnScreen

import javafx.scene.control.Dialog; //导入依赖的package包/类
/**
     * Utility method to center a Dialog/Alert on the middle of the current
     * screen. Used to workaround a "bug" with the current version of JavaFX (or
     * the SWT/JavaFX embedding?) where alerts always show on the primary
     * screen, not necessarily the current one.
     *
     * @param dialog
     *            The dialog to reposition. It must be already shown, or else
     *            this will do nothing.
     * @param referenceNode
     *            The dialog should be moved to the same screen as this node's
     *            window.
     */
    public static void centerDialogOnScreen(Dialog<?> dialog, Node referenceNode) {
        Window window = referenceNode.getScene().getWindow();
        if (window == null) {
            return;
        }
        Rectangle2D windowRectangle = new Rectangle2D(window.getX(), window.getY(), window.getWidth(), window.getHeight());

        List<Screen> screens = Screen.getScreensForRectangle(windowRectangle);
        Screen screen = screens.stream()
                .findFirst()
                .orElse(Screen.getPrimary());

        Rectangle2D screenBounds = screen.getBounds();
        dialog.setX((screenBounds.getWidth() - dialog.getWidth()) / 2 + screenBounds.getMinX());
//        dialog.setY((screenBounds.getHeight() - dialog.getHeight()) / 2 + screenBounds.getMinY());
    }
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:30,代码来源:JfxUtils.java

示例4: bind

import javafx.scene.control.Dialog; //导入依赖的package包/类
public void bind(Dialog<?> dialog) {
  if (map.containsKey(dialog)) {
    return;
  }
  ChangeListener<? super SkinStyle> listener = (ob, o, n) -> {
    dialog.getDialogPane().getStylesheets().remove(o.getURL());
    dialog.getDialogPane().getStylesheets().add(n.getURL());
  };
  if (skin.get() != null) {
    dialog.getDialogPane().getStylesheets().add(skin.get().getURL());
  }
  skin.addListener(listener);
  map.put(dialog, listener);
  dialog.setOnHidden(e -> {
    skin.removeListener(listener);
    map.remove(dialog);
  });
}
 
开发者ID:XDean,项目名称:JavaFX-EX,代码行数:19,代码来源:SkinManager.java

示例5: showPropertySheet

import javafx.scene.control.Dialog; //导入依赖的package包/类
/**
 * Creates the menu for editing the properties of a widget.
 *
 * @param tile the tile to pull properties from
 * @return     the edit property menu
 */
private void showPropertySheet(Tile<?> tile) {
  ExtendedPropertySheet propertySheet = new ExtendedPropertySheet();
  propertySheet.getItems().add(new ExtendedPropertySheet.PropertyItem<>(tile.getContent().titleProperty()));
  Dialog<ButtonType> dialog = new Dialog<>();
  if (tile.getContent() instanceof Widget) {
    ((Widget) tile.getContent()).getProperties().stream()
        .map(ExtendedPropertySheet.PropertyItem::new)
        .forEachOrdered(propertySheet.getItems()::add);
  }

  dialog.setTitle("Edit widget properties");
  dialog.getDialogPane().getStylesheets().setAll(AppPreferences.getInstance().getTheme().getStyleSheets());
  dialog.getDialogPane().setContent(new BorderPane(propertySheet));
  dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CLOSE);

  dialog.showAndWait();
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:24,代码来源:WidgetPaneController.java

示例6: show

import javafx.scene.control.Dialog; //导入依赖的package包/类
public void show() {
    paneController.load();
    ResourceBundle i18n = toolBox.getI18nBundle();
    Dialog<ButtonType> dialog = new Dialog<>();
    dialog.setTitle(i18n.getString("prefsdialog.title"));
    dialog.setHeaderText(i18n.getString("prefsdialog.header"));
    GlyphsFactory gf = MaterialIconFactory.get();
    Text settingsIcon = gf.createIcon(MaterialIcon.SETTINGS, "30px");
    dialog.setGraphic(settingsIcon);
    dialog.getDialogPane()
            .getButtonTypes()
            .addAll(ButtonType.OK, ButtonType.CANCEL);
    dialog.getDialogPane()
            .setContent(paneController.getRoot());
    dialog.getDialogPane()
            .getStylesheets()
            .addAll(toolBox.getStylesheets());
    Optional<ButtonType> buttonType = dialog.showAndWait();
    buttonType.ifPresent(bt -> {
        if (bt == ButtonType.OK) {
            paneController.save();
        }
    });
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:25,代码来源:PreferencesDialogController.java

示例7: init

import javafx.scene.control.Dialog; //导入依赖的package包/类
protected void init() {

        String tooltip = toolBox.getI18nBundle().getString("buttons.upon");
        MaterialIconFactory iconFactory = MaterialIconFactory.get();
        Text icon = iconFactory.createIcon(MaterialIcon.VERTICAL_ALIGN_BOTTOM, "30px");
        Text icon2 = iconFactory.createIcon(MaterialIcon.VERTICAL_ALIGN_BOTTOM, "30px");
        initializeButton(tooltip, icon);

        ResourceBundle i18n = toolBox.getI18nBundle();
        Dialog<String> dialog = dialogController.getDialog();
        dialog.setTitle(i18n.getString("buttons.upon.dialog.title"));
        dialog.setHeaderText(i18n.getString("buttons.upon.dialog.header"));
        dialog.setContentText(i18n.getString("buttons.upon.dialog.content"));
        dialog.setGraphic(icon2);
        dialog.getDialogPane().getStylesheets().addAll(toolBox.getStylesheets());

    }
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:18,代码来源:UponBC.java

示例8: start

import javafx.scene.control.Dialog; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
    MediaService mediaService = DemoConstants.newMediaService();
    AnnotationService annotationService = DemoConstants.newAnnotationService();

    Label label = new Label();
    Button button = new JFXButton("Browse");
    Dialog<Media> dialog = new SelectMediaDialog(annotationService,
            mediaService, uiBundle);
    button.setOnAction(e -> {
        Optional<Media> media = dialog.showAndWait();
        media.ifPresent(m -> label.setText(m.getUri().toString()));
    });

    VBox vBox = new VBox(label, button);
    Scene scene = new Scene(vBox, 400, 200);
    primaryStage.setScene(scene);
    primaryStage.show();

    primaryStage.setOnCloseRequest(e -> {
        Platform.exit();
        System.exit(0);
    });

}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:26,代码来源:SelectMediaDialogDemo.java

示例9: showAbout

import javafx.scene.control.Dialog; //导入依赖的package包/类
public void showAbout(ActionEvent actionEvent) throws URISyntaxException {
    Dialog<Void> dialog = new Dialog<>();
    dialog.setTitle("Tenhou Visualizer について");
    dialog.initOwner(this.root.getScene().getWindow());
    dialog.getDialogPane().getStylesheets().add(this.getClass().getResource(Main.properties.getProperty("css")).toExternalForm());
    dialog.getDialogPane().setGraphic(new ImageView(new Image("/logo.png")));
    dialog.getDialogPane().setHeaderText("TenhouVisualizer v0.3");
    final Hyperlink oss = new Hyperlink("open-source software");
    final URI uri = new URI("https://crazybbb.github.io/tenhou-visualizer/thirdparty");
    oss.setOnAction(e -> {
        try {
            Desktop.getDesktop().browse(uri);
        } catch (IOException e1) {
            throw new UncheckedIOException(e1);
        }
    });
    dialog.getDialogPane().setContent(new TextFlow(new Label("Powered by "), oss));
    dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
    dialog.showAndWait();
}
 
开发者ID:CrazyBBB,项目名称:tenhou-visualizer,代码行数:21,代码来源:AppController.java

示例10: show

import javafx.scene.control.Dialog; //导入依赖的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;
}
 
开发者ID:NMSU-SIC-Club,项目名称:JavaFX_Tutorial,代码行数:35,代码来源:FXDialogController.java

示例11: enableClosing

import javafx.scene.control.Dialog; //导入依赖的package包/类
public static void enableClosing(Alert alert) {
    try {
        Field dialogField = Dialog.class.getDeclaredField("dialog");
        dialogField.setAccessible(true);

        Object dialog = dialogField.get(alert);
        Field stageField = dialog.getClass().getDeclaredField("stage");
        stageField.setAccessible(true);

        Stage stage = (Stage) stageField.get(dialog);
        stage.setOnCloseRequest(null);
        stage.addEventFilter(KeyEvent.KEY_PRESSED, keyEvent -> {
            if (keyEvent.getCode() == KeyCode.ESCAPE) {
                ((Button) alert.getDialogPane().lookupButton(ButtonType.OK)).fire();
            }
        });
    } catch (Exception ex) {
        // no point
        ex.printStackTrace();
    }
}
 
开发者ID:helios-decompiler,项目名称:standalone-app,代码行数:22,代码来源:DialogHelper.java

示例12: loadCombinason

import javafx.scene.control.Dialog; //导入依赖的package包/类
private void loadCombinason() {
    scene.addEventFilter(KeyEvent.KEY_PRESSED, t -> {
        String codeStr = t.getCode().toString();
        if(!key.toString().endsWith("_"+codeStr)){
             key.append("_").append(codeStr);
        }
    });
    scene.addEventFilter(KeyEvent.KEY_RELEASED, t -> {
        if(key.length()>0) {
            if("_CONTROL_C_L_E_M".equals(key.toString())){
             // Create the custom dialog.
                Dialog<Void> dialog = new Dialog<>();
                dialog.setTitle(Configuration.getBundle().getString("ui.menu.easteregg"));
                dialog.setHeaderText(null);
                dialog.setContentText(null);
                dialog.setGraphic(new ImageView(this.getClass().getResource("images/goal.gif").toString()));
                dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);
                dialog.showAndWait();
            }
            key = new StringBuilder();
        }
    });
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:24,代码来源:MainApp.java

示例13: loadDefaultConfigFile

import javafx.scene.control.Dialog; //导入依赖的package包/类
private void loadDefaultConfigFile() {
    Task task = new Task() {
        @Override
        protected Object call() throws Exception {
            logger.debug("Started loading default config file");
            try (InputStream inputStream = AppInitializerImpl.class.getResourceAsStream("/pdr_configuration.xml");
                 OutputStream outputStream = new FileOutputStream(configFile)) {
                int read;
                byte[] bytes = new byte[1024];
                while ((read = inputStream.read(bytes)) != -1) {
                    outputStream.write(bytes, 0, read);
                }
                logger.debug("Successfully loaded default configuration file");
            } catch (IOException e) {
                initExceptions.add(new RuntimeException("Failed to copy default configuration to " + configFile.getAbsolutePath(), e));
            }
            return null;
        }
    };
    Dialog dialog = FXMLUtils.getProgressDialog(primaryStage, task);
    executeTask(task);
    dialog.showAndWait();
}
 
开发者ID:m-krajcovic,项目名称:photometric-data-retriever,代码行数:24,代码来源:AppInitializerImpl.java

示例14: handleExport

import javafx.scene.control.Dialog; //导入依赖的package包/类
@FXML
private void handleExport() {
    File file = FXMLUtils.showSaveFileChooser(resources.getString("choose.output.file"),
            lastSavePath,
            "PDR report",
            stage,
            new FileChooser.ExtensionFilter("Text file (*.txt)", "*.txt"));
    if (file != null) {
        updateLastSavePath(file.getParent());
        Task task = new Task() {
            @Override
            protected Object call() throws Exception {
                try (OutputStream out = new FileOutputStream(file)) {
                    byte[] byteArray = text.get().getBytes();
                    out.write(byteArray, 0, byteArray.length);
                } catch (IOException e) {
                    logger.error(e);
                }
                return null;
            }
        };
        Dialog dialog = FXMLUtils.getProgressDialog(stage, task);
        executor.execute(task);
        dialog.showAndWait();
    }
}
 
开发者ID:m-krajcovic,项目名称:photometric-data-retriever,代码行数:27,代码来源:SearchReportDialogController.java

示例15: initialize

import javafx.scene.control.Dialog; //导入依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
    
    logoImg.setImage(UIUtils.getImage("logo.png"));

    Dialog diag = new Dialog();
    diag.getDialogPane().setContent(borderPane);
    diag.getDialogPane().setBackground(Background.EMPTY);
    diag.setResizable(true);

    UIUtils.setIcon(diag);

    ButtonType closeButton = new ButtonType("Close", ButtonBar.ButtonData.OK_DONE);

    diag.getDialogPane().getButtonTypes().addAll(closeButton);
    diag.setTitle("About HueSense");

    Optional<ButtonType> opt = diag.showAndWait();
    if (opt.isPresent() && opt.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) {
        // nothing
    }

}
 
开发者ID:dainesch,项目名称:HueSense,代码行数:24,代码来源:AboutPresenter.java


注:本文中的javafx.scene.control.Dialog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。