可执行 Jar 的画布比使用 Eclipse Runner 的画布小 [英] Executable Jar has a Smaller Canvas than using the Eclipse Runner

查看:28
本文介绍了可执行 Jar 的画布比使用 Eclipse Runner 的画布小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的项目导出为一个可执行的 jar 文件,但由于某种原因,在框架中的画布上绘图的框架变小了.换句话说,当我从 Eclipse 运行它时,屏幕以某种方式变得更小 (1536 x 864),它是 1080p.

我认为可能是编译器或 .jar 导出的问题,所以我尝试使用 IntelliJ Idea 但得到了相同的结果:编译器中为 1080p,但从 .jar 中运行为 1536 x 864

所以下面的代码会产生描述的结果:

GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();//device.getDisplayMode() 返回 1920 x 1080 和其他一些统计数据//device.getDefaultConfiguration().getBounds() 从 Eclipse(或 IntelliJ)运行时返回 1920 x 1080,但从导出的 .jar 文件运行时返回 1536 x 864.

我希望 .jar 文件仍为 1080p,而不是更改为较小的尺寸.我认为问题可能出在我的电脑本身,但我不知道如何检查.我无法在另一台计算机上复制这个问题,但会检查更多.如果需要,我很乐意提供任何图片;我现在不能.任何帮助将不胜感激!

注意:这是另一个问题的扩展,在我部分解决问题时可能会有所帮助 为什么 Java 全屏独占模式没有运行我的最大屏幕分辨率?.最初的问题是,即使在 Eclipse 中,我的屏幕尺寸也比预期的要小.部分解决方案是我将工作区环境从版本 11 恢复到 Java 版本 1.8.

编辑澄清:问题围绕 GraphicsDevice 和我对画布和框架的引用只是正在发生的事情的一个例子.

编辑 2:基于上一个问题的潜在解决方案是 Java 解释器可能存在问题.Eclipse 正在尝试使用 Java 11 版解释代码,所以我的计算机可能正在尝试使用 11 版解释 Java.我不知道它是如何工作的,但也许我可以尝试在我的计算机上卸载 Java 11 版本的所有实例.

编辑 3:编辑 2 有效.我卸载了 11 版并连接了 1.8 版,一切运行良好:)

解决方案

如果这对任何人有帮助:编辑问题的 3 有效.

I'm trying to export my project as an executable jar file but for some reason, the frame of drawing on the Canvas in a Frame became smaller. In other words, the screen somehow became smaller (1536 x 864) from when I ran it from Eclipse where it was 1080p.

I have thought that maybe the compiler or .jar export may be the issue so I tried using IntelliJ Idea but got the same results: 1080p in the compiler but 1536 x 864 running from the .jar

So the code below would produce the described results:

GraphicsDevice device = GraphicsEnvironment
         .getLocalGraphicsEnvironment().getDefaultScreenDevice();
// device.getDisplayMode() returns 1920 x 1080 and some other stats
// device.getDefaultConfiguration().getBounds() returns 1920 x 1080 when run from Eclipse (or IntelliJ) but returns 1536 x 864 when ran from the exported .jar file.

I would like the .jar file to still be in 1080p instead of changing to a smaller size. I'm thinking that the issue may lie in my computer itself but I have no clue how to check this or not. I could not replicate this issue on one other computer but will be checking more. I would be happy to supply any pictures if requested; I can't at the moment. Any help would be greatly appreciated!

Note: This is an extension of another question that may be helpful where I partially resolved the issue Why isn't Java Fullscreen Exclusive Mode running my max screen resolution?. The original problem was that even in Eclipse I had a smaller screen size than anticipated. The partial solution was that I reverted my workspace environment to Java version 1.8 from version 11.

Edit for Clarification: The issue surrounds the GraphicsDevice and my reference to the Canvas and Frame is just an example of what's going on.

Edit 2: A potential solution that is based on the previous question is that there may just be an issue with the Java interpreter. Eclipse was trying to interpret the code using Java version 11 so maybe my computer is trying to interpret Java using version 11. I don't know how it works but maybe I can try uninstalling all instances of Java 11 versions on my computer.

Edit 3: Edit 2 worked. I uninstalled version 11 and hooked up version 1.8 and everything ran well :)

解决方案

In case this helps anyone: Edit 3 of the question worked.

这篇关于可执行 Jar 的画布比使用 Eclipse Runner 的画布小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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