Windows和Macintosh GUI [英] Windows and Macintosh GUI

查看:70
本文介绍了Windows和Macintosh GUI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。



我正在开发JAVA中的一些小应用程序,需要在Windows和Mac OS上运行。只是有点花哨,因为是小应用程序我喜欢改变完整的GUI,取决于哪个窗口检测我的应用程序。



我正在使用此功能的Windows:< br $>


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



因为我在运行应用程序时在Windows上开发应用程序,所以外观会像Windows窗体一样被更改,但是我不确定如果把这个放到mac上是否会起作用(我无法在Windows上测试它)看):



UIManager.setLookAndFeel(com.sun.java.swing.plaf.mac.MacLookAndFeel);



请告诉我Mac OS是否会识别这个并改变外观或需要加上我的代码中的东西。



谢谢,干杯

解决方案

你想要的是SystemLookAndFeel。它将根据环境显示GUI。



 尝试 { 
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (例外e){
// 做点什么。
}





如果你想了解更多关于外观的信息 - 和 - 感觉,看看这个: http://docs.oracle.com/javase/ tutorial / uiswing / lookandfeel / plaf.html


Hi.

I'm developing some little app in JAVA which need to run both on windows and mac os. Just to be a little fancy because is small app i like to change the full GUI depending which windows detects my app.

I'm using this function for windows:

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

Because I'm developing the app on windows when I run the app the look is changed as windows form, but I'm not sure if this will work if put this one for mac(I can't test it on windows this look):

UIManager.setLookAndFeel("com.sun.java.swing.plaf.mac.MacLookAndFeel");

Please tell me if the Mac Os will recognize this one and change the look or need plus something to put in my code.

Thanks, Cheers

解决方案

What you want is the SystemLookAndFeel. It will display the GUI according to the environment.

try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
    // Do something.
}



If you want some more info on the look-and-feels, have a look at this: http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html


这篇关于Windows和Macintosh GUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆