在Windowbuilder中的Windows风格

huangapple go评论108阅读模式
英文:

Windows style in Windowbuilder

问题

嘿,我编写了一个计算器。在设计选项卡中,我将其设置为 Windows 主题,但当我导出时,却是那个讨厌的“Metal”主题。它看起来不像我设计的那样。诚挚的 Jonathan

在 Eclipse 视图中

在我导出它时

英文:

Hey I coded a calculator. In the design Tab I set it to Windows but wehn I export it, its the nasty "Metal" theme. And it dosnt look like i designed it. Sincerely Jonathan

The Eclipse View

When I export it

答案1

得分: 0

解决方案如下:

首先需要进入:Window(窗口) > Preferences(首选项) > WindowBuilder(窗体生成器) > Swing(Swing界面生成器) > LookAndFeel(外观设置)

然后勾选 Windows(Windows外观) > Apply(应用) & Close(关闭)

  1. public static void main(String[] args) {
  2. try {
  3. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  4. } catch(Exception e) {
  5. System.out.println("设置本地外观时出错:" + e);
  6. }
  7. EventQueue.invokeLater(new Runnable() {
  8. public void run() {
  9. try {
  10. YourFrame frame = new YourFrame();
  11. frame.setVisible(true);
  12. } catch (Exception e) {
  13. e.printStackTrace();
  14. }
  15. }
  16. });
  17. }
英文:

The solution is:

First you need to go to: Window > Preferences > WindowBuilder > Swing > LookAndFeel

Then you tick Windows > Apply & Close

  1. public static void main(String[] args) {
  2. try {
  3. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  4. } catch(Exception e) {
  5. System.out.println("Error setting native LAF: " + e);
  6. }
  7. EventQueue.invokeLater(new Runnable() {
  8. public void run() {
  9. try {
  10. YourFrame frame = new YourFrame();
  11. frame.setVisible(true);
  12. } catch (Exception e) {
  13. e.printStackTrace();
  14. }
  15. }
  16. });
  17. }

huangapple
  • 本文由 发表于 2020年9月22日 00:22:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/63996280.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定