英文:
Windows style in Windowbuilder
问题
嘿,我编写了一个计算器。在设计选项卡中,我将其设置为 Windows 主题,但当我导出时,却是那个讨厌的“Metal”主题。它看起来不像我设计的那样。诚挚的 Jonathan
英文:
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
答案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();
}
}
});
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论