UIMANAGER初始化需要很长时间 - 任何方面都可以解决吗?

发布于 2025-01-25 07:34:24 字数 1011 浏览 2 评论 0原文

在我的标准Java秋千应用程序中,我通过各种Uimanager.put方法设置了标准字体,边框,颜色等。

我注意到我的UI应用程序需要超过10秒钟的时间才能启动,并设法将其追溯到第一个Uimanager.put。第一个呼叫显然初始化了L& f。一旦初始化,事情就合理了。

这是一个完美的例子(即您甚至不需要实例化UI即可看到它):

import java.awt.Font;

import javax.swing.UIManager;

public class SlowUIManagerPut {
    public static void main(String[] args) {
        Font font = new Font("Tahoma", Font.PLAIN, 10);
        long startingTime = System.currentTimeMillis();

        System.out.printf("1st UIManager.put: %d\n", System.currentTimeMillis() - startingTime);
    
        UIManager.put("Button.font", font);
        
        System.out.printf("Done with 1st.  2nd UIManager.put: %d\n", System.currentTimeMillis() - startingTime);
        
        UIManager.put("TextField.font", font);
        
        System.out.printf("Done with 2nd: %d\n", System.currentTimeMillis() - startingTime);
    }
}

有人有工作或某种方法可以加快速度吗?

顺便说一句:这不是我的机器。我正在使用Hexacore I9、64GB RAM和2TB SSD(M2 NVME)磁盘空间的Dell Precision 7730跑步。

In my standard Java Swing apps, I setup standard fonts, borders, colors, etc. via the various UIManager.put methods.

I noticed my UI apps were taking upwards of 10 seconds to startup and managed to trace it down to the first UIManager.put. The first call apparently initializes the L&F. Once initialized, things are reasonable.

Here is a perfect example (i.e. you don't even need to instantiate a UI to see it):

import java.awt.Font;

import javax.swing.UIManager;

public class SlowUIManagerPut {
    public static void main(String[] args) {
        Font font = new Font("Tahoma", Font.PLAIN, 10);
        long startingTime = System.currentTimeMillis();

        System.out.printf("1st UIManager.put: %d\n", System.currentTimeMillis() - startingTime);
    
        UIManager.put("Button.font", font);
        
        System.out.printf("Done with 1st.  2nd UIManager.put: %d\n", System.currentTimeMillis() - startingTime);
        
        UIManager.put("TextField.font", font);
        
        System.out.printf("Done with 2nd: %d\n", System.currentTimeMillis() - startingTime);
    }
}

Does anyone have a work-around or some way to speed it up?

BTW: It isn't my machine. I'm running on a Dell Precision 7730 with hexacore I9, 64GB ram and 2TB SSD (M2 NVME) disk space.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文