關(guān)鍵字: swing apple ui
首先去下載蘋果風(fēng)格的jar包。quaqua.jar 下載地址:https://quaqua.dev.java.net/
swing的界面通常是通過UIManager.setLookAndFeel來控制的。
設(shè)置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("數(shù)據(jù)庫連接向?qū)?);
- f.setSize(600, 400);
- f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- f.setVisible(true);
- }
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("數(shù)據(jù)庫連接向?qū)?);f.setSize(600, 400);f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//關(guān)閉窗口事件f.setVisible(true);}
就這樣吧!看風(fēng)格附圖如下