nimrodlfutils.java

来自「Java自定义窗体JsFrame。简介见:http://jason0086.sp」· Java 代码 · 共 78 行

JAVA
78
字号
package com.hfkj.jsframe.example;

import java.awt.Color;
import java.io.FileInputStream;
import java.util.Properties;

import com.nilo.plaf.nimrod.NimRODLookAndFeel;
import com.nilo.plaf.nimrod.NimRODTheme;

/**
 * 
 * @version 1.0 01/05/09
 * @author Jason (MSN:www.jason0086.com@hotmail.com)
 */
public class NimRodLfUtils {
	
	/**
	 * Returns the nimrod look and feel corresponding the file with the path specified by the given string.
	 * @param themeFile the path of the theme's file
	 * @return the nimrod look and feel
	 */
	public static NimRODLookAndFeel getLookAndFeel(String themeFile) {
		NimRODLookAndFeel xLaf = null;
		if ((themeFile != null) 
				&& (themeFile.length() > 0)) {
			try {
				NimRODTheme xThm = new NimRODTheme();
	        	xLaf = new NimRODLookAndFeel();
				Properties xPrp = new Properties();
				xPrp.load(new FileInputStream(themeFile));
				if (xPrp.getProperty("nimrodlf.selection") != null) {
					xThm.setPrimary(Color.decode(xPrp.getProperty("nimrodlf.selection")));
				}
				if (xPrp.getProperty("nimrodlf.background") != null) {
					xThm.setSecondary(Color.decode(xPrp.getProperty("nimrodlf.background")));
				}
				if (xPrp.getProperty("nimrodlf.p1") != null) {
					xThm.setPrimary1(Color.decode(xPrp.getProperty("nimrodlf.p1")));
				}
				if (xPrp.getProperty("nimrodlf.p2") != null) {
					xThm.setPrimary2(Color.decode(xPrp.getProperty("nimrodlf.p2")));
				}
				if (xPrp.getProperty("nimrodlf.p3") != null) {
					xThm.setPrimary3(Color.decode(xPrp.getProperty("nimrodlf.p3")));
				}
				if (xPrp.getProperty("nimrodlf.s1") != null) {
					xThm.setSecondary1(Color.decode(xPrp.getProperty("nimrodlf.s1")));
				}
				if (xPrp.getProperty("nimrodlf.s2") != null) {
					xThm.setSecondary2(Color.decode(xPrp.getProperty("nimrodlf.s2")));
				}
				if (xPrp.getProperty("nimrodlf.s3") != null) {
					xThm.setSecondary3(Color.decode(xPrp.getProperty("nimrodlf.s3")));
				}
				if (xPrp.getProperty("nimrodlf.w") != null) {
					xThm.setWhite(Color.decode(xPrp.getProperty("nimrodlf.w")));
				}
				if (xPrp.getProperty("nimrodlf.b") != null) {
					xThm.setBlack(Color.decode(xPrp.getProperty("nimrodlf.b")));
				}
				if (xPrp.getProperty("nimrodlf.menuOpacity") != null) {
					xThm.setMenuOpacity(Integer.parseInt(xPrp.getProperty("nimrodlf.menuOpacity")));
				}
				if (xPrp.getProperty("nimrodlf.frameOpacity") != null) {
					xThm.setFrameOpacity(Integer.parseInt(xPrp.getProperty("nimrodlf.frameOpacity")));
				}
				// set theme
				NimRODLookAndFeel.setCurrentTheme(xThm);
	        } catch ( Exception ex) {
				ex.printStackTrace();
			}
	        return xLaf;
		}
		return null;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?