首先去下载苹果风格的jar包。quaqua.jar 下载地址:https://quaqua.dev.java.net/
swing的界面通常是通过UIManager.setLookAndFeel来控制的。
设置UIManager的代码:
public static void main(String args[]){
System.setProperty("Quaqua.tabLayoutPolicy", "wrap");
if (!System.getProperty("os.name").toLowerCase().startsWith("mac")) {
try {
Methods.invokeStatic(JFrame.class,
"setDefaultLookAndFeelDecorated", Boolean.TYPE,
Boolean.TRUE);
Methods.invokeStatic(JDialog.class,
"setDefaultLookAndFeelDecorated", Boolean.TYPE,
Boolean.TRUE);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
try {
UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");
} catch (Exception e) {
}
DBConnFrame f = new DBConnFrame();
f.setTitle("数据库连接向导");
f.setSize(600, 400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//关闭窗口事件
f.setVisible(true);
}
就这样吧!看风格附图如下