当setResizable为false时,AnchorPane显示白色边框(JavaFX) [英] AnchorPane shows a white border when setResizable is false (JavaFX)

查看:734
本文介绍了当setResizable为false时,AnchorPane显示白色边框(JavaFX)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,当我使用setResizable(false)时,我的场景会显示一个白色边框。
当我没有设置它时,false工作正常,但我需要设置为false。

My problem is that when I use setResizable(false) one white border is shown on my scene. When I don't set it false works fine, but I need to set it false.

代码:

 Scene scene = new Scene(new StackPane());  

        LoginManager loginManager = new LoginManager(scene);
        loginManager.showLoginScreen();
        primaryStage.setResizable(false);
        primaryStage.setScene(scene);
        primaryStage.show();

我的ImageView在我的AnchorPane里面

My ImageView is inside of my AnchorPane

<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="900.0" xmlns:fx="http://javafx.com/fxml" fx:controller="br.com.facilit.target.app.desktop.view.MainViewController">
  <children>
    <ImageView id="background" fitHeight="600.0" fitWidth="900.0" pickOnBounds="true">
      <image>
        <Image url="@../images/background.jpg" preserveRatio="true" smooth="true" />
      </image>

推荐答案

我遇到了同样的问题,我这样解决了:

I had the same issue, I resolved in this way:

primaryStage.setScene(scene);

primaryStage.setWidth(900);
primaryStage.setHeight(600);
primaryStage.setResizable(false);

primaryStage.show();

你必须在设置resizable属性之前设置场景并设置手动宽度/高度。这解决了我的问题。

You have to set the scene before setting the resizable property and set the width/height manually. This has solved my problem.

这篇关于当setResizable为false时,AnchorPane显示白色边框(JavaFX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆