?? lookandfeel.java
字號:
package com.flat;
import java.awt.Color;
import java.awt.Font;
import java.awt.image.Kernel;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
import javax.swing.BorderFactory;
import javax.swing.UIDefaults;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.MetalTheme;
public class LookAndFeel extends MetalLookAndFeel{
String fichTheme = "";
protected static MetalTheme theme;
public LookAndFeel(){
super();
Theme th = new Theme();
String f1,f2,f3,b1,b2,b3,selection,background,w,b,opMenu,opFrame;
String fiche=null;
try{
fiche = System.getProperty("theme.themeFile");
fiche = (fiche==null ? "themeFile.theme":fiche);
Properties props = new Properties();
InputStream res = null;
try{
res = new FileInputStream(fiche);
}catch(Exception ex){
fiche = (fiche.equals("themeFile.theme")?"/"+fiche:fiche);
res = this.getClass().getResourceAsStream(fiche);
}
props.load(res);
selection = props.getProperty("theme.selection");
background = props.getProperty("theme.background");
f1 = props.getProperty("theme.f1");
f2 = props.getProperty("theme.f2");
f3 = props.getProperty("theme.f3");
b1 = props.getProperty("theme.b1");
b2 = props.getProperty("theme.b2");
b3 = props.getProperty("theme.b3");
w = props.getProperty("theme.w");
b = props.getProperty("theme.b");
opMenu = props.getProperty("theme.menuOpacity");
opFrame = props.getProperty("theme.frameOpacity");
th = Utils.iniCustomColors(th, selection, background, f1, f2, f3, b1, b2, b3, w, b, opMenu, opFrame);
fichTheme = fiche;
}catch(Exception e){
th = new Theme();
}
try{
selection = System.getProperty("theme.selection");
background = System.getProperty("theme.background");
f1 = System.getProperty("theme.f1");
f2 = System.getProperty("theme.f2");
f3 = System.getProperty("theme.f3");
b1 = System.getProperty("theme.b1");
b2 = System.getProperty("theme.b2");
b3 = System.getProperty("theme.b3");
w = System.getProperty( "theme.w");
b = System.getProperty( "theme.b");
opMenu = System.getProperty( "theme.menuOpacity");
opFrame = System.getProperty( "theme.frameOpacity");
th = Utils.iniCustomColors(th, selection, background, f1, f2, f3, b1, b2, b3, w, b, opMenu, opFrame);
}catch(Exception e){
if(fichTheme.length()==0){
th = new Theme();
}
}
setCurrentTheme(th);
float[] elements = new float[Utils.MATRIX_FAT*Utils.MATRIX_FAT];
for (int i=0; i<elements.length; i++){
elements[i]=0.1f;
}
int mid = Utils.MATRIX_FAT/2+1;
elements[mid*mid]=.2f;
Utils.kernelFat = new Kernel(Utils.MATRIX_FAT,Utils.MATRIX_FAT,elements);
elements = new float[Utils.MATRIX_THIN*Utils.MATRIX_THIN];
for(int i =0; i<elements.length;i++){
elements[i] = 0.1f;
}
mid = Utils.MATRIX_THIN/2+1;
elements[mid*mid] = .2f;
Utils.kernelThin = new Kernel(Utils.MATRIX_THIN,Utils.MATRIX_THIN,elements);
}
public static void setCurrentTheme( MetalTheme t) {
MetalLookAndFeel.setCurrentTheme( t);
theme = t;
Utils.rollColor = null;
}
@Override
protected void initComponentDefaults(UIDefaults table) {
super.initComponentDefaults(table);
try {
ColorUIResource cFore = (ColorUIResource)table.get( "MenuItem.disabledForeground");
ColorUIResource cBack = (ColorUIResource)table.get( "MenuItem.foreground");
ColorUIResource col = Utils.getColorTercio( cBack, cFore);
table.put( "MenuItem.disabledForeground", col);
table.put( "Label.disabledForeground", col);
table.put( "CheckBoxMenuItem.disabledForeground", col);
table.put( "Menu.disabledForeground", col);
table.put( "RadioButtonMenuItem.disabledForeground", col);
table.put( "ComboBox.disabledForeground", col);
table.put( "Button.disabledText", col);
table.put( "ToggleButton.disabledText", col);
table.put( "CheckBox.disabledText", col);
table.put( "RadioButton.disabledText", col);
ColorUIResource col2 = Utils.getColorTercio( LookAndFeel.getWhite(),
(Color)table.get( "TextField.inactiveBackground"));
table.put( "TextField.inactiveBackground", col2);
}
catch ( Exception ex) {
ex.printStackTrace();
}
table.put( "MenuBar.border", Borders.getMenuBarBorder());
Font fontMenu = ((Font)table.get( "Menu.font")).deriveFont( Font.BOLD);
table.put( "MenuItem.acceleratorFont", fontMenu);
table.put( "RadioButtonMenuItem.acceleratorFont", fontMenu);
table.put( "CheckBoxMenuItem.acceleratorFont", fontMenu);
ColorUIResource colAcce = Utils.getColorTercio( (ColorUIResource)table.get( "MenuItem.foreground"),
(ColorUIResource)table.get( "MenuItem.acceleratorForeground")
);
table.put( "MenuItem.acceleratorForeground", colAcce);
table.put( "RadioButtonMenuItem.acceleratorForeground", colAcce);
table.put( "CheckBoxMenuItem.acceleratorForeground", colAcce);
table.put( "BorderPopupMenu.SombraBajIcon", Utils.loadRes("/com/flat/icons/SombraMenuBajo.png"));
table.put( "BorderPopupMenu.SombraDerIcon", Utils.loadRes( "/com/flat/icons/SombraMenuDer.png"));
table.put( "BorderPopupMenu.SombraEsqIcon", Utils.loadRes( "/com/flat/icons/SombraMenuEsq.png"));
table.put( "BorderPopupMenu.SombraUpIcon", Utils.loadRes( "/com/flat/icons/SombraMenuUp.png"));
table.put( "BorderPopupMenu.SombraIzqIcon", Utils.loadRes( "/com/flat/icons/SombraMenuIzq.png"));
table.put( "Tree.collapsedIcon", IconFactory.getTreeCollapsedIcon());
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -