蘋果風格的swing外觀

首先去下載蘋果風格的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);
	}

 就這樣吧!看風格附圖如下

 

發佈了6 篇原創文章 · 獲贊 1 · 訪問量 3235
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章