Getting java applications to look native on window

2020-06-03 04:18发布

Is it possible to use Java to create apps that look native on Windows? I don't care if the solution is portable or not, because I only plan to target windows users. I am using Scala if that matters.

Sorry for the lack of details, but I have never used Java before so I'm not even sure if this is possible.

8条回答
不美不萌又怎样
2楼-- · 2020-06-03 04:37

It's strange no one has mentioned JGoodies yet.

The JGoodies Windows look&feel focuses on a precise emulation on Windows 95/98/NT/ME/2000 in the following areas: menus, icons, colors, borders, fonts, font sizes, insets, and widget dimensions. It honors the screen resolution (96dpi vs. 120 dpi) to adjust sizes, insets, and widget dimensions. (Source)

查看更多
Summer. ? 凉城
3楼-- · 2020-06-03 04:37

Yes, Java does have a Windows-native look and feel available on Windows. Look up how to change your look-and-feel and that should take you in the right direction.

查看更多
smile是对你的礼貌
4楼-- · 2020-06-03 04:37

Your should use native Look&Feel

查看更多
等我变得足够好
5楼-- · 2020-06-03 04:41

See here: Java™ Tutorials: How to Set the Look and Feel

try {
    // Set System L&F
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} 
catch (UnsupportedLookAndFeelException e) {
   // handle exception
}
查看更多
爷、活的狠高调
6楼-- · 2020-06-03 04:43

You'd do something like:

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

(Which of course works only on Windows.) The result looks and feels reasonably native. More info e.g. here.

查看更多
家丑人穷心不美
7楼-- · 2020-06-03 04:44

You have to use Windows look and feel.

You can specify it at the command line:

java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel MyApp

Or in code

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

Here are the details: How to set the look and feel

查看更多
登录 后发表回答