UIMANAGER初始化需要很长时间 - 任何方面都可以解决吗?
在我的标准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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论