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


Java Stage.getWidth方法代码示例

本文整理汇总了Java中javafx.stage.Stage.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Stage.getWidth方法的具体用法?Java Stage.getWidth怎么用?Java Stage.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.stage.Stage的用法示例。


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

示例1: populateRenderCells

import javafx.stage.Stage; //导入方法依赖的package包/类
private void populateRenderCells(Group squares, Stage primaryScene) {
    int SPACING = 1;

    screenCenter = new Point((int) primaryScene.getWidth() / (2 * (sideSize + SPACING)),
            (int) primaryScene.getHeight() / (2 * (sideSize + SPACING)));
    renderMap = new HashMap<>();

    for (int y = 0; y < height / (sideSize + SPACING); y++) {
        for (int x = 0; x < width / (sideSize + SPACING); x++) {
            Point position = new Point(x, y).minus(screenCenter);
            Rectangle square = new Rectangle(sideSize, sideSize, Color.BLACK);
            square.setX(x * (sideSize + SPACING));
            square.setY(y * (sideSize + SPACING));
            if (!position.isOrigin()) {
                renderMap.put(position, square);
            } else {
                square.setFill(Color.ORANGE);
            }
            squares.getChildren().add(square);
        }
    }
}
 
开发者ID:slemonide,项目名称:GraphSpace,代码行数:23,代码来源:Main.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: create

import javafx.stage.Stage; //导入方法依赖的package包/类
public void create(Stage primaryStage) {
    this.primaryStage = primaryStage;
    FunnyCreator.getLogger().info("Creating primary view");

    ScreenUtils.to(primaryStage, 960, 480);
    ScreenUtils.center(primaryStage);

    WebView view = new WebView();
    this.engine = view.getEngine();

    engine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != State.SUCCEEDED) {
            return;
        }

        FunnyCreator.getLogger().info("Showing view");
        primaryStage.show();

        FunnyCreator.getLogger().info("Injecting FGC bridge");
        JSObject window = (JSObject) engine.executeScript("window");
        window.setMember("FunnyGuildsCreator", new FunnyBridge());

        creator.runAsync(() -> {
            try {
                creator.load();
            } catch (Exception e) {
                e.printStackTrace();
                AlertUtils.alert("FunnyCreator Exception", "Cannot load creator", ExceptionUtils.getStackTrace(e), creator::shutdown);
            }
        });
    });

    String style = IOUtils.toString(getClass().getResourceAsStream("/panel/front.css"), Charset.forName("UTF-8"));
    String script = IOUtils.toString(getClass().getResourceAsStream("/panel/front.js"), Charset.forName("UTF-8"));
    String html = IOUtils.toString(getClass().getResourceAsStream("/panel/front.html"), Charset.forName("UTF-8"));

    String content = html
            .replace("{{STYLE}}", style)
            .replace("{{SCRIPT}}", script)
            .replace("{{VERSION}}", FunnyConstants.VERSION);
    engine.loadContent(content);

    Scene scene = new Scene(view, primaryStage.getWidth(), primaryStage.getHeight());
    primaryStage.getIcons().add(new Image(FunnyCreator.class.getResourceAsStream("/icon.png")));
    primaryStage.initStyle(StageStyle.UNDECORATED);
    primaryStage.setTitle("FunnyGuilds Creator " + FunnyConstants.VERSION);
    primaryStage.setScene(scene);
}
 
开发者ID:FunnyGuilds,项目名称:FunnyCreator,代码行数:49,代码来源:FunnyView.java


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