gpt4 book ai didi

java - JButton Windows 外观

转载 作者:行者123 更新时间:2023-11-30 03:37:36 26 4
gpt4 key购买 nike

我想要 JButton 的外观:

lookandfeel1

我尝试通过这种方式更改 Windows 的外观:

  UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

但显示为:

lookandfeel2

提前致谢!

最佳答案

将评论序列带到一个独立的答案:

    // sets the look and feel to be that of the operating system's
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException |
InstantiationException |
IllegalAccessException |
UnsupportedLookAndFeelException e) {
e.printStackTrace();
}

我给 kiheru 投了赞成票,但看来你设置的时间不对。 您需要在显示组件之前运行此代码 - 我通常将其插入到启动应用程序的原始 run() 方法中,尽管如果我包含闪屏,情况会有所不同。

此外,将来(尤其在谈论 GUI 代码时,这可能会变得可怕)如果您发布可运行的代码示例,人们会更喜欢它,这样我们就可以准确地看到您可能在哪里出错: )

关于java - JButton Windows 外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27486281/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com