在Windowbuilder中的Windows风格

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

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(关闭)

public static void main(String[] args) {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch(Exception e) {
        System.out.println("设置本地外观时出错:" + e);
    }
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                YourFrame frame = new YourFrame();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
英文:

The solution is:

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

Then you tick Windows > Apply & Close

public static void main(String[] args) {
	try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch(Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }
	EventQueue.invokeLater(new Runnable() {
		public void run() {
			try {
				YourFrame frame = new YourFrame();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
}

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:

确定