當前位置: 首頁>>代碼示例>>Java>>正文


Java Stage.setOnShowing方法代碼示例

本文整理匯總了Java中javafx.stage.Stage.setOnShowing方法的典型用法代碼示例。如果您正苦於以下問題:Java Stage.setOnShowing方法的具體用法?Java Stage.setOnShowing怎麽用?Java Stage.setOnShowing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.stage.Stage的用法示例。


在下文中一共展示了Stage.setOnShowing方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: start

import javafx.stage.Stage; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setOnShowing(event -> uiHandlers.onShow());
    BorderPane border = new BorderPane();
    hbox = new HBox();
    border.setTop(hbox);
    hbox.setMinHeight(60);
    hbox.setAlignment(Pos.CENTER_LEFT);
    hbox.setBackground(new Background(new BackgroundFill(Color.web("#2196f3"), CornerRadii.EMPTY, Insets.EMPTY)));
    hbox.setPadding(new Insets(10));

    menu = new VBox();
    menu.setPadding(new Insets(20, 0, 0, 0));
    BorderStroke borderStroke = new BorderStroke(Color.GRAY, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(0,1,0,0));

    menu.setBorder(new Border(borderStroke));
    menu.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
    menu.setMinWidth(50);
    menu.setSpacing(20);
    border.setLeft(menu);


    primaryStage.setTitle("Todo list");

    Text text = new Text("Todo List");
    text.setFill(Color.WHITE);
    text.setFont(Font.font("Verdana", FontWeight.BOLD, 25));

    center = new VBox();
    center.setPadding(new Insets(20));
    center.setSpacing(10);
    Image image = new Image(getClass().getResourceAsStream("/add.png"));
    Button add = new Button("", new ImageView(image));
    add.setCursor(Cursor.HAND);
    add.setBackground(Background.EMPTY);
    add.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE);
    add.setOnAction(event -> uiHandlers.onCreate());

    border.setCenter(center);

    hbox.setPadding(new Insets(10, 10, 10, 10));

    final Pane spacer = new Pane();
    HBox.setHgrow(spacer, Priority.ALWAYS);
    spacer.setMinSize(10, 1);
    hbox.getChildren().addAll(text, spacer, add);

    primaryStage.setScene(new Scene(border, 500, 500));
    primaryStage.show();
}
 
開發者ID:GwtDomino,項目名稱:domino-todolist,代碼行數:51,代碼來源:DesktopLayoutView.java

示例2: ProgressBarView

import javafx.stage.Stage; //導入方法依賴的package包/類
/**
 * Create instance of {@link ProgressBarView}.
 */
public ProgressBarView() {
    try {
        final Stage newStage = new Stage();
        newStage.setResizable(false);

        final URL resource = getClass().getResource(PROGRESS_BAR_VIEW);
        fxmlLoader = new FXMLLoader(resource);

        final Stage primaryStage = Hygene.getInstance().getPrimaryStage();
        newStage.initOwner(primaryStage);
        newStage.initStyle(StageStyle.UTILITY);
        newStage.initModality(Modality.APPLICATION_MODAL);

        final double centerXPosition = primaryStage.getX() + primaryStage.getWidth() / 2;
        final double centerYPosition = primaryStage.getY() + primaryStage.getHeight() / 2;

        newStage.setOnShowing(event -> newStage.hide());
        newStage.setOnShown(event -> {
            newStage.setX(centerXPosition - newStage.getWidth() / 2);
            newStage.setY(centerYPosition - newStage.getHeight() / 2);
            newStage.show();
        });

        setStage(newStage);
    } catch (final UIInitialisationException e) {
        LOGGER.error("Progress bar view could not be loaded.", e);
    }
}
 
開發者ID:ProgrammingLife2017,項目名稱:hygene,代碼行數:32,代碼來源:ProgressBarView.java

示例3: init

import javafx.stage.Stage; //導入方法依賴的package包/類
public void init(Stage stage, Main main) {
    this.stage = stage;
    this.main = main;
    stage.setOnShowing(event -> {
        Config config = main.getRootController().getConfig();
        Book book = config.getBook();
        if (book != null) {
            from.getSelectionModel().select(book.getLang().split("-")[0]);
            to.getSelectionModel().select(book.getLang().split("-")[1]);
            fromField.setText(book.getName());
            toField.setText(book.getRusName());
            fromAuthor.setText(book.getAuthor());
            thumbnail.setVisible(true);
            thumbnail.setImage(new Image(new File(main.getRootController().getFile(), book.getThumbnail()).toURI().toString()));

            for (Book.Lang lang : book.getLangs()) {
                 for (LangItem field : langItems) {
                    if (field.getLang().lang.equals(lang.lang)) {
                        field.author.setText(lang.author);
                        field.name.setText(lang.name);
                        break;
                    }
                }
            }
        }
    });
    chapters = main.getRootController().validate();
    if (chapters == null) {
        send.setDisable(true);
        Toast.makeText(stage, "Не во всех главах количество русских абзацев совпадает с количеством английских");
    }
}
 
開發者ID:KursX,項目名稱:Parallator,代碼行數:33,代碼來源:BookDialogController.java


注:本文中的javafx.stage.Stage.setOnShowing方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。