Java 9中的JFrame扩展 [英] JFrame scaling in Java 9

查看:122
本文介绍了Java 9中的JFrame扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在左侧的Java 9u4和Windows 7右侧的8u144下运行的代码完全相同。

Exactly the same code running under Java 9u4 on the left and 8u144 on the right on Windows 7.

Java 9似乎使窗口更大。造成这种情况的原因是什么 - JEP 263?如何禁用它?

Java 9 seems to making the window larger. What is causing this - JEP 263? How can I disable it?

public class SimpleFrame {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.getContentPane().add(new JLabel("Horse"));
        frame.setSize(new Dimension(200, 100));
        frame.setVisible(true);
    }
}


推荐答案

我在物质错误报告中找到了这个模糊的选项。这解决了Swing应用程序的问题。

I found this obscure option in a substance bug report. This fixes the issue for Swing applications.

-Dsun.java2d.uiScale = 1.0

如果您正在使用JavaFX,则需要

If you're using JavaFX you'll need

-Dprism.allowhidpi = false

很遗憾,我找不到这些选项的官方文档

Unfortunately I cannot find official documentation for either of these options

这篇关于Java 9中的JFrame扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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