⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toniclookandfeel.java

📁 用于java swing的皮肤软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.digitprop.tonic;


import java.awt.*;

import java.net.*;


import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;



/**	Represents the Tonic Look and Feel, and provides the UIManager with
 * 	the settings for Tonic.
 * 
 * 	@version	1.0.5
 * 
 * 	@author		Markus Fischer
 *
 *  	<p>This software is under the <a href="http://www.gnu.org/copyleft/lesser.html" target="_blank">GNU Lesser General Public License</a>
 */

/*
 * ------------------------------------------------------------------------
 * Copyright (C) 2004 Markus Fischer
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free 
 * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 * MA 02111-1307  USA
 * 
 * You can contact the author at:
 *    Markus Fischer
 *    www.digitprop.com
 *    info@digitprop.com
 * ------------------------------------------------------------------------
 */
public class TonicLookAndFeel extends MetalLookAndFeel
{
	private static final boolean				isSlim=false;
	
	/**	The text foreground color */
	private static final ColorUIResource 	textFg=new ColorUIResource(Color.BLACK);
	
	/** 	The window background color */
	private static final ColorUIResource	windowBg=new ColorUIResource(220, 220, 220);
	
	/** 	The background for inactive windows */
	private static final ColorUIResource 	inactiveBg=new ColorUIResource(180, 180, 180);
	
	/**	The background for active windows */
	private static final ColorUIResource	activeBg=new ColorUIResource(220, 220, 220);
	
	/**	The highlight for active resources */
	private static final ColorUIResource 	activeHighlight=new ColorUIResource(Color.WHITE);
	
	/** 	The shadow for active resources */
	private static final ColorUIResource	activeShadow=new ColorUIResource(150, 150, 150);
	
	/**	The light shadow for active resources */
	private static final ColorUIResource 	activeLightShadow=new ColorUIResource(200, 200, 200);
	
	/**	The foreground color for selections */
	private static final ColorUIResource 	selFg=new ColorUIResource(Color.WHITE);
	
	/**	The background color for selections */
	private static final ColorUIResource	selBg=new ColorUIResource(0, 0, 153);
	
	/**	The background color for active ToolButtons */
	private static final ColorUIResource	toolButtonActiveBg=new ColorUIResource(173,173,209);
	
	/**	The border color for active ToolButtons */
	private static final ColorUIResource	toolButtonBorder=selBg;
	
	/**	The color of the focus */
	private static final ColorUIResource	focusColor=selBg; //focusColor=new ColorUIResource(100, 90, 130);
	
	/**	The color of inactive borders */
	private static final ColorUIResource	inactiveBorderColor=new ColorUIResource(100, 90, 90);
	
	/**	The border of components */
	private static final ColorUIResource	borderColor=new ColorUIResource(100, 90, 90);
	
	/**	The background for fields */
	private static final ColorUIResource	fieldBg=new ColorUIResource(Color.WHITE);
	
	/**	The color for tree lines */
	private static final ColorUIResource	treeLineColor=new ColorUIResource(220, 220, 220);
	
	/**	Inactive window gradient color 1 */
	private static final ColorUIResource	inactiveGradColor1=new ColorUIResource(200, 200, 200);
	
	/**	Inactive window gradient color 2 */
	private static final ColorUIResource	inactiveGradColor2=new ColorUIResource(Color.WHITE);

	/**	Active window gradient color 1 */	
	private static final ColorUIResource 	activeGradColor1=selBg;
	
	/**	Active window gradient color 2 */
	private static final ColorUIResource	activeGradColor2=new ColorUIResource(Color.WHITE);
	
	/**	Background for tool tips */	
	private static final ColorUIResource	toolTipBg=new ColorUIResource(255, 255, 240);
	
	/**	Standard font */
	private static FontUIResource				stdFont=new FontUIResource("Tahoma", Font.PLAIN, 11);
	
	/**	Standard bold font */
	private static final FontUIResource		stdBoldFont=new FontUIResource("Tahoma", Font.BOLD, 11);
	
	/**	Helper border to be used in compound border */
	private static final Border 				hb5=BorderFactory.createLineBorder(fieldBg, 1);
	
	/** 	Helper border to be used in compound border */
	private static final Border 				hb6=BorderFactory.createLineBorder(borderColor);
	
	/**	Helper border to be used in compound border */
	private static final Border				hb7=BorderFactory.createLineBorder(borderColor);
	
	/**	Helper border to be used in compound border */
	private static final Border				hb8=BorderFactory.createCompoundBorder(hb5, hb6);
	
	/**	Helper border to be used in compound border */
	private static final BorderUIResource.CompoundBorderUIResource internalFrameBorder=new BorderUIResource.CompoundBorderUIResource(hb7, hb8);
	
	/**	Helper border to be used in compound border */		
	private static final BorderUIResource	internalFrameBorder2=new BorderUIResource(new InternalFrameBorder(borderColor, inactiveBg, Color.WHITE));
	
	private static final BorderUIResource.LineBorderUIResource	plainDialogBorder=new BorderUIResource.LineBorderUIResource(Color.BLACK);	

	/**	Helper border to be used in compound border */
	private static final Border				hb1=BorderFactory.createMatteBorder(0, 0, 1, 0, activeHighlight);
	
	/**	Helper border to be used in compound border */
	private static final Border 				hb2=BorderFactory.createMatteBorder(0, 0, 1, 0, activeShadow);
	
	/**	Border for separating the menu (and toolbars) from the main panel */
	private static final BorderUIResource.CompoundBorderUIResource menuBarBorder=new BorderUIResource.CompoundBorderUIResource(hb1, hb2);
	
	/**	Helper border to be used in compound border */
	private static final Border				hb9=BorderFactory.createMatteBorder(0, 0, 0, 1, activeHighlight);
	
	/**	Helper border to be used in compound border */
	private static final Border 				hb10=BorderFactory.createMatteBorder(0, 0, 0, 1, activeShadow);
	
	/**	Border for separating the menu (and toolbars) from the main panel */
	private static final BorderUIResource.CompoundBorderUIResource toolBarVerticalBorder=new BorderUIResource.CompoundBorderUIResource(hb9, hb10);	

	private static final BorderUIResource.EmptyBorderUIResource	menuBorder=new BorderUIResource.EmptyBorderUIResource(2, 5, 2, 5);
	
	/**	Helper border to be used in compound border */
	private static final Border				hb3=BorderFactory.createEmptyBorder(2, 2, 2, 2);
	
	/**	Helper border to be used in compound border */
	private static final Border				hb4=BorderFactory.createLineBorder(borderColor);
	
	/**	Border for progress bars */
	private static final BorderUIResource.CompoundBorderUIResource progressBarBorder=new BorderUIResource.CompoundBorderUIResource(hb4, hb3);

	/**	Simple, single pixel border */
	private static final BorderUIResource.LineBorderUIResource popupMenuBorder=new BorderUIResource.LineBorderUIResource(focusColor);
	
	/**	Simple, single pixel border */
	private static final BorderUIResource.LineBorderUIResource simpleBorder=new BorderUIResource.LineBorderUIResource(borderColor);
	
	/**	Border for combo boxes */
	private static final BorderUIResource.LineBorderUIResource comboBoxBorder=new BorderUIResource.LineBorderUIResource(borderColor);
	
	
	/**	Is called by the UIManager.setLookAndFeel() method and
	 * 	creates the look and feel specific defaults table.
	 * 
	 * 	@see	UIManager#setLookAndFeel(LookAndFeel)
	 */ 
	public UIDefaults getDefaults()
	{
		UIDefaults result=super.getDefaults();	
			
		// Bind the UI classes to the respective components
		String packageName="com.digitprop.tonic.";		
		result.put("ButtonUI", 					packageName+"ButtonUI");
		result.put("FileChooserUI", 			packageName+"FileChooserUI");
		result.put("LabelUI",					packageName+"LabelUI");
		result.put("MenuBarUI", 				packageName+"MenuBarUI");
		result.put("MenuItemUI", 				packageName+"MenuItemUI");
		result.put("MenuUI", 					packageName+"MenuUI");
		result.put("SeparatorUI", 				packageName+"SeparatorUI");
		result.put("PopupMenuSeparatorUI", 	packageName+"PopupMenuSeparatorUI");
		result.put("CheckBoxMenuItemUI", 	packageName+"CheckBoxMenuItemUI");
		result.put("DesktopIconUI", 			packageName+"DesktopIconUI");
		result.put("RadioButtonMenuItemUI", packageName+"RadioButtonMenuItemUI");
		result.put("ComboBoxUI", 				packageName+"ComboBoxUI");
		result.put("ScrollBarUI", 				packageName+"ScrollBarUI");
		result.put("ToggleButtonUI", 			packageName+"ToggleButtonUI");
		result.put("RadioButtonUI", 			packageName+"RadioButtonUI");
		result.put("CheckBoxUI", 				packageName+"CheckBoxUI");
		result.put("InternalFrameUI", 		packageName+"InternalFrameUI");
		result.put("OptionPaneUI", 			packageName+"OptionPaneUI");
		result.put("RootPaneUI",				packageName+"RootPaneUI");		
		result.put("TabbedPaneUI", 			packageName+"TabbedPaneUI");
		result.put("TableUI", 					packageName+"TableUI");
		result.put("TableHeaderUI", 			packageName+"TableHeaderUI");
		result.put("ToolBarUI", 				packageName+"ToolBarUI");
		result.put("ToolButtonUI", 			packageName+"ToolButtonUI");
		result.put("ProgressBarUI", 			packageName+"ProgressBarUI");
		result.put("SliderUI", 					packageName+"SliderUI");
		result.put("SplitPaneUI", 				packageName+"SplitPaneUI");
		result.put("ScrollPaneUI", 			packageName+"ScrollPaneUI");
		result.put("SpinnerUI", 				packageName+"SpinnerUI");
		
		// Set parameters for visual appearance
		result.put("Button.font", stdFont);
		result.put("Button.borderColor", borderColor);
		result.put("Button.border", null);
		result.put("Button.focusBorderColor", focusColor);
		result.put("Button.disabledBorderColor", inactiveBorderColor);
		result.put("Button.background", windowBg); //new ColorUIResource(Color.WHITE));
		result.put("Button.highlight", activeHighlight);
		result.put("Button.textShiftOffset", new Integer(5));
		result.put("Button.margin", new InsetsUIResource(0, 7, 0, 7));

		result.put("CheckBox.background", windowBg);
		result.put("CheckBox.font", stdFont);

		result.put("CheckBoxMenuItem.background", windowBg);
		result.put("CheckBoxMenuItem.font", stdFont);
		result.put("CheckBoxMenuItem.selectionBackground", selBg);
		result.put("CheckBoxMenuItem.selectionForeground", selFg);
		result.put("CheckBoxMenuItem.acceleratorFont", stdFont);
		result.put("CheckBoxMenuItem.acceleratorForeground", textFg);
		result.put("CheckBoxMenuItem.acceleratorSelectionForeground", selFg);
		result.put("CheckBoxMenuItem.border", menuBorder);
		
		result.put("ComboBox.font", stdFont);
		result.put("ComboBox.background", fieldBg);
		result.put("ComboBox.selectionBackground", selBg);
		result.put("ComboBox.selectionForeground", selFg);
		result.put("ComboBox.border", comboBoxBorder);
		
		result.put("control", windowBg);
		result.put("controlHighlight", activeHighlight);
		result.put("controlShadow", activeShadow);

		result.put("Desktop.background", Color.WHITE);

		result.put("FileChooser.newFolderIcon", makeIcon(getClass(),"icons/filechooser_newfolder.gif"));
		result.put("FileChooser.upFolderIcon", makeIcon(getClass(),"icons/filechooser_back.gif"));
		result.put("FileChooser.homeFolderIcon", makeIcon(getClass(),"icons/home.gif"));
		result.put("FileChooser.detailsViewIcon", makeIcon(getClass(),"icons/filechooser_details.gif"));
		result.put("FileChooser.listViewIcon", makeIcon(getClass(),"icons/filechooser_list.gif"));
		result.put("FileChooser.folderIcon", makeIcon(getClass(),"icons/tree_closed.gif"));
		
		result.put("FormattedTextField.font", stdFont);
		result.put("FormattedTextField.border", new BorderUIResource.MatteBorderUIResource(1, 1, 1, 0, borderColor));
		result.put("FormattedTextField.selectionBackground", selBg);
		result.put("FormattedTextField.selectionForeground", selFg);

		result.put("InternalFrame.optionDialogBorder", internalFrameBorder); //new BorderUIResource.LineBorderUIResource(borderColor, 2));
		result.put("InternalFrame.paletteBorder", internalFrameBorder); //new BorderUIResource.LineBorderUIResource(borderColor, 2));
		result.put("InternalFrame.border", internalFrameBorder2); //new BorderUIResource.LineBorderUIResource(borderColor, 2));
	
		result.put("InternalFrame.closeIcon", LookAndFeel.makeIcon(getClass(),"icons/frame_close.gif"));
		result.put("InternalFrame.icon", LookAndFeel.makeIcon(getClass(),"icons/frame_icon.gif"));
		result.put("InternalFrame.maximizeIcon", LookAndFeel.makeIcon(getClass(),"icons/frame_max.gif"));
		result.put("InternalFrame.minimizeIcon", LookAndFeel.makeIcon(getClass(),"icons/frame_max.gif"));
		result.put("InternalFrame.iconifyIcon", LookAndFeel.makeIcon(getClass(),"icons/frame_min.gif"));
		result.put("InternalFrame.inactiveTitleBackground", inactiveGradColor1);
		result.put("InternalFrame.inactiveTitleGradientColor", inactiveGradColor2);
		result.put("InternalFrame.activeTitleBackground", activeGradColor1);
		result.put("InternalFrame.activeTitleGradientColor", activeGradColor2);
		result.put("InternalFrame.activeTitleForeground", selFg); 

		result.put("Label.font", stdFont);

		result.put("List.selectionForeground", selFg);
		result.put("List.selectionBackground", selBg);
		result.put("List.font", stdFont);
		result.put("List.focusCellHighlightBorder", new BorderUIResource.LineBorderUIResource(selBg));

		result.put("Menu.font", stdFont);
		result.put("Menu.background", windowBg);
		result.put("Menu.selectionBackground", selBg);
		result.put("Menu.selectionForeground", selFg);
		result.put("Menu.border", menuBorder);
				
		result.put("MenuBar.background", windowBg);
		result.put("MenuBar.border", menuBarBorder);
	
		result.put("MenuItem.font", stdFont);
		result.put("MenuItem.background", windowBg);
		result.put("MenuItem.selectionBackground", selBg);
		result.put("MenuItem.selectionForeground", selFg);
		result.put("MenuItem.acceleratorFont", stdFont);
		result.put("MenuItem.acceleratorForeground", textFg);
		result.put("MenuItem.acceleratorSelectionForeground", selFg);
		result.put("MenuItem.border", menuBorder);
		
		result.put("OptionPane.background", windowBg);
		result.put("OptionPane.border", new BorderUIResource.LineBorderUIResource(windowBg, 10));
		result.put("OptionPane.buttonAreaBorder", null);
		result.put("OptionPane.errorDialog.border.background", windowBg);
		result.put("OptionPane.errorDialog.titlePane.background", windowBg);
		result.put("OptionPane.questionDialog.border.background", windowBg);
		result.put("OptionPane.questionDialog.titlePane.background", windowBg);
		result.put("OptionPane.warningDialog.border.background", windowBg);
		result.put("OptionPane.warningDialog.titlePane.background", windowBg);	

		result.put("Panel.background", windowBg);
		
		result.put("PopupMenuSeparator.foreground", borderColor);
		result.put("PopupMenuSeparator.background", windowBg);
		result.put("PopupMenu.border", popupMenuBorder);
		
		result.put("ProgressBar.foreground", selBg);
		result.put("ProgressBar.cellLength", new Integer(10));
		result.put("ProgressBar.cellSpacing", new Integer(2));
		result.put("ProgressBar.border", progressBarBorder);
		
		result.put("RadioButton.background", windowBg);
		result.put("RadioButton.font", stdFont);
		result.put("RadioButton.focusColor", focusColor);

		result.put("RadioButtonMenuItem.background", windowBg);
		result.put("RadioButtonMenuItem.font", stdFont);
		result.put("RadioButtonMenuItem.selectionBackground", selBg);
		result.put("RadioButtonMenuItem.selectionForeground", selFg);
		result.put("RadioButtonMenuItem.acceleratorFont", stdFont);
		result.put("RadioButtonMenuItem.acceleratorForeground", textFg);
		result.put("RadioButtonMenuItem.acceleratorSelectionForeground", selFg);
		result.put("RadioButtonMenuItem.border", menuBorder);

⌨️ 快捷键说明

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