java - 同一个生成的.JAR文件在不同的电脑上是不同的

标签 java javafx jar

我们在 Java 中创建了一个内部工具 -> Jar。它是在 JavaFX 中创建的。

.jar 在 11 个人的计算机中,有 9 台工作正常,但其中 2 台的 .jar 大小不同。出于某种原因,那两个人的 window 被缩小了。我还将附上图像来显示差异。

首先,工作电脑中的.jar(您可以清楚地看到.jar的边缘,并且所有字段都清晰可见:

http://imgur.com/ycm6gk6

第二,损坏的 .jar(我已经画出了您可以看到字段/窗口被剪切的区域,只是框架中的东西由于某种原因不适合那里):

如果需要,我可以提供更多信息。但目前看来,对于这两台计算机来说,这些字段不适合框架,这可能是 java 版本或操作系统的差异吗?

编辑: 添加一些有关布局等的信息(所有元素都在网格中):

    @Override
    public void start(final Stage stage) throws Exception {
    final Group root = new Group();

    GridPane grid0 = new GridPane();
    final Scene scene = new Scene(root, 1030, 768);
    final GridPane grid = new GridPane();
    grid.setHgap(5); //The gap properties manage the spacing between the rows and columns.
    grid.setVgap(5); //Vahe iga rea ja veeru vahel pmst.
    grid.setPadding(new Insets(40, 20, 20, 20)); //while the padding property manages the space around the edges of the grid pane. Ehk kogu raami sisu vahe ��rtest.
    //In this example, there are 10 pixels of padding on each side.
    //grid.setGridLinesVisible(true); //N�itab t�pselt joonduse �ra

    GridPane grid2 = new GridPane();
    grid2.setHgap(5); //The gap properties manage the spacing between the rows and columns.
    grid2.setVgap(5); //Vahe iga rea ja veeru vahel pmst.
    grid2.setPadding(new Insets(40, 20, 20, 20)); //while the padding property manages the space around the edges of the grid pane. Ehk kogu raami sisu vahe ��rtest.

    final GridPane grid3 = new GridPane();
    grid3.setHgap(5); //The gap properties manage the spacing between the rows and columns.
    grid3.setVgap(5); //Vahe iga rea ja veeru vahel pmst.
    grid3.setPadding(new Insets(40, 20, 20, 20)); //while the padding property manages the space around the edges of the grid pane. Ehk kogu raami sisu vahe ��rtest.**strong text**
    grid0.add(grid, 0, 0);
    Line joon2 = new Line(0, 0, 0, 800);
    grid0.add(joon2, 1, 0);
    grid0.add(grid2, 2, 0);
    final Line joon3 = new Line(0, 0, 0, 800);
    grid0.add(joon3, 3, 0);
    grid0.add(grid3, 4, 0);
    root.getChildren().

            add(grid0);

    root.getChildren().

            add(menuBar);

    stage.setResizable(false); //Cannot resize the Bit!
    stage.setScene(scene);
    stage.show();

最佳答案

感谢大家的回复,我已经解决了问题!

有两个选项可以解决此问题:

  1. 更改“屏幕分辨率”下的窗口缩放比例。
  2. 我删除了硬编码的场景大小,并让大小通过网格中元素的大小来计算,因此对于每台计算机来说它都是动态的。

关于java - 同一个生成的.JAR文件在不同的电脑上是不同的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37858037/

相关文章:

java - 除非 ObjectProperty 的源发生更改,否则不会触发 ChangeListener

JavaFX ComboBox - 显示文本但在选择时返回 ID

api - 编辑 jar 文件中包含的任何文件

java - Spring 和 Guice : when DI frameworks create proxies?

java - 测试 Axis 1.4 SOAP 调用时有条件地模拟异常/返回值

JavaFX ChoiceBox 添加具有类型安全性的分隔符

java - 包结构的 jar 执行错误

java - 如何制作包含 DLL 文件的 JAR 文件?

java - 多线程会导致每个任务花费更长的时间吗?

java - 如何使用关键字过滤 RSS 提要?