【发布时间】:2016-03-06 19:08:00
【问题描述】:
我有一个桌面 LibGDX 项目,并且我的主 (DesktopLauncher) 类扩展了 JFrame(它将是未修饰且不可调整大小的)。我在 LwjglCanvas 中渲染 LibGDX OpenGL 画布,该画布作为组件添加到容器中。现在这是一个奇怪的问题:有时我可以看到画布周围有 3-4-5px 的边框,这会导致一些可疑的调整大小。
这是我的课:
public DesktopLauncher() {
this.setUndecorated(true);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setTitle("Evil Engine (v. Lambda)");
Container container = this.getContentPane();
this.canvas = new LwjglCanvas(new Main(DesktopLauncher.inst));
// this.canvas.getCanvas().setLocation(200, -200);
// height of the task bar
int taskBarSize = Toolkit.getDefaultToolkit().getScreenInsets(this.getGraphicsConfiguration()).bottom;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.canvas.getCanvas().setSize(screenSize.width, screenSize.height - taskBarSize);
container.add(this.canvas.getCanvas(), BorderLayout.CENTER);
this.pack();
this.setVisible(true);
}
当 setUndecorated 为 true 时可以看出问题。我试图移动画布(setLocation() 行),我看到它周围有一个边框:
我尝试了很多东西,但没有任何效果:
- 我更改了布局类型
- 我创建了一个新的 JPanel,将画布添加到其中并设置为 setContentPane()
- 试过setPreferedSize、setMaximumSize、setMinimumSize
- 搜索 ...setBorder() 或 ..setResizable() 方法没有成功
我怎样才能摆脱画布周围的可怕边框?
【问题讨论】:
-
删除 jframe 扩展并在启动之前将其放在您的代码中 System.setProperty("org.lwjgl.opengl.Window.undecorated", "true");
标签: java swing opengl libgdx jframe