UIManager用户默认、外观默认、系统默认的应用

/** 打印swing用户默认、外观默认、系统默认的键与值 **/
		Hashtable table = javax.swing.UIManager.getDefaults();
		Enumeration e = table.keys();
		for (; e.hasMoreElements();)
		{
			Object key = e.nextElement();
			Object value = table.get(key);
			System.out.println(key + " = " + value);
		}

		/** 设置全局菜单选中时的颜色 **/
		UIManager.put("Menu.selectionBackground", Color.red);
		
//		/** setLookAndFeel是用于设置窗口为Window样式 **/
//		try
//		{
//			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//		}
//		catch (ClassNotFoundException e1)
//		{
//			e1.printStackTrace();
//		}
//		catch (InstantiationException e1)
//		{
//			e1.printStackTrace();
//		}
//		catch (IllegalAccessException e1)
//		{
//			e1.printStackTrace();
//		}
//		catch (UnsupportedLookAndFeelException e1)
//		{
//			e1.printStackTrace();
//		}
		
		/** 更新生效上面的设置 **/
		SwingUtilities.updateComponentTreeUI(this);

你可能感兴趣的:(swing)