javax.swing.UIDefaults#keys ( )源码实例Demo

下面列出了javax.swing.UIDefaults#keys ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: littleluck   文件: DefaultsDisplay.java
public UIDefaultsTableModel() {
    // make a local copy of the defaults table in case the look and feel changes
    defaults = new UIDefaults();
    keys = new ArrayList<Object>();
    UIDefaults realDefaults = UIManager.getDefaults();
    Enumeration keysEnum = realDefaults.keys();
    while (keysEnum.hasMoreElements()) {
        Object key = keysEnum.nextElement();
        if (!defaults.containsKey(key)) {
            keys.add(key);
            defaults.put(key, realDefaults.get(key));
        } else {
            System.out.println("found duplicate key:"+key);
        }
    }
}
 
源代码2 项目: beautyeye   文件: DefaultsDisplay.java
public UIDefaultsTableModel() {
    // make a local copy of the defaults table in case the look and feel changes
    defaults = new UIDefaults();
    keys = new ArrayList<Object>();
    UIDefaults realDefaults = UIManager.getDefaults();
    Enumeration keysEnum = realDefaults.keys();
    while (keysEnum.hasMoreElements()) {
        Object key = keysEnum.nextElement();
        if (!defaults.containsKey(key)) {
            keys.add(key);
            defaults.put(key, realDefaults.get(key));
        } else {
            System.out.println("found duplicate key:"+key);
        }
    }
}
 
源代码3 项目: netbeans   文件: ColorEditor.java
/** Initialized fields used in Swing Palette. */
private static void initSwingConstants() {
    if (swingColorNames != null)
        return;

    UIDefaults def = UIManager.getDefaults ();
    Enumeration e = def.keys ();
    
    java.util.TreeSet<String> names = new java.util.TreeSet<String>();
    
    while (e.hasMoreElements ()) {
        Object k = e.nextElement ();
        if (! (k instanceof String))
            continue;
        Object v = def.get (k);
        if (! (v instanceof Color))
            continue;
        names.add((String)k);
    }
    
    swingColorNames = new String [names.size ()];
    names.toArray(swingColorNames);
    swingColors = new Color [swingColorNames.length];
    
    int i, k = swingColorNames.length;
    for (i = 0; i < k; i++)
        swingColors [i] = (Color) def.get (swingColorNames [i]);
        }
 
源代码4 项目: freecol   文件: FreeColLookAndFeel.java
/**
 * Set the default font in all UI elements.
 *
 * @param defaultFont A {@code Font} to use by default.
 */
public static void installFont(Font defaultFont) {
    UIDefaults u = UIManager.getDefaults();
    java.util.Enumeration<Object> keys = u.keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (u.get(key) instanceof javax.swing.plaf.FontUIResource) {
            u.put(key, defaultFont);
        }
    }
}
 
源代码5 项目: ios-image-util   文件: IOSImageUtil.java
public static void main(String[] args) {
	try {
		/* Mac OS X El Capitan has a little problem with mac look and feel. Ignore it.
		for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
			if (info.getClassName().equals("com.apple.laf.AquaLookAndFeel")) {
				System.setProperty("apple.laf.useScreenMenuBar", "true");
				System.setProperty("com.apple.mrj.application.apple.menu.about.name", "ios-image-util");
				UIManager.setLookAndFeel(info.getClassName());
				break;
			}
		}
		*/

		// Use anti-aliasing font on Windows platform in Japanese by default.
		System.setProperty("awt.useSystemAAFontSettings", "lcd"); // Maybe not effective. Don't care.
		ResourceBundle resource = ResourceBundle.getBundle("application");
		if (resource.containsKey("font.default.name") && System.getProperty("file.separator").equals("\\")) { // Windows only
			UIDefaults uiDefaults = UIManager.getLookAndFeelDefaults();
			for (Enumeration<Object> enu = uiDefaults.keys(); enu.hasMoreElements();) {
				String key = enu.nextElement().toString();
				Font font;
				if (key.toLowerCase().endsWith("font") && (font = uiDefaults.getFont(key)) != null) {
					uiDefaults.put(key, new Font(resource.getString("font.default.name"), font.getStyle(), font.getSize()));
				}
			}
		}

		long l1 = System.currentTimeMillis();
		MainFrame mainFrame = new MainFrame();
		mainFrame.setLocationByPlatform(true);

		File defaultProperties = new File(getDefaultDirectory(mainFrame), DEFAULT_PROPERTIES_FILENAME);
		if (defaultProperties.exists()) {
			boolean loadSystemProperties = true;
			boolean forceNew = false;
			for (int i = 0; i < args.length; i++) {
				String arg = args[i].toLowerCase();
				if (arg.startsWith("/")) arg = "-".concat(arg.substring(1));
				if (arg.equals("-r") || arg.equals("-reset")) { loadSystemProperties = false; break; }
				if (arg.equals("-b") || arg.equals("-batch")) { loadSystemProperties = false; break; }
				if (arg.equals("-h") || arg.equals("-help")) { loadSystemProperties = false; break; }
				if (arg.equals("-n") || arg.equals("-new")) { forceNew = true; }
			}
			if (loadSystemProperties) {
				mainFrame.loadProperties(defaultProperties, true, forceNew);
			}
		}

		if (args.length > 0) {
			if (!initialize(mainFrame, args)) {
				if (mainFrame.isBatchMode()) {
					System.exit(1);
				}
			}
		}

		if (mainFrame.isBatchMode()) {
			int exitCode = 0;
			if (!mainFrame.isSilentMode()) {
				System.out.println(String.format("START: %s", (new java.util.Date(l1)).toString()));
				System.out.println(String.format("  Initializing takes %.2f secs.", ((double)(System.currentTimeMillis() - l1) / 1000d)));
				System.out.println();
			}
			if (mainFrame.isGenerateImagesReqested() && !mainFrame.generate()) {
				exitCode = 1;
				usage(mainFrame);
			}
			if (mainFrame.isSplitImageRequested() && !mainFrame.batchSplit()) {
				exitCode = 1;
				usage(mainFrame);
			}
			long l2 = System.currentTimeMillis();
			if (!mainFrame.isSilentMode()) {
				System.out.println(String.format("FINISH: %s", (new java.util.Date(l2)).toString()));
				System.out.println(String.format("  Generate images takes %.2f secs.", ((double)(l2 - l1) / 1000d)));
				System.out.println();
			}
			System.exit(exitCode);
		} else {
			if (mainFrame.isCheckForUpdatesOnStartUp()) {
				mainFrame.checkForUpdatesInBackground();
			}
			mainFrame.initializeGUI();
			mainFrame.setVisible(true);
		}
	} catch (Throwable t) {
		t.printStackTrace(System.err);
		System.exit(1);
	}
}