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

📄 xplookandfeel.java

📁 Swing Windows XP 外观和感觉 BeanSoft 修改版, 2003年 原始的作者: XP 外观和感觉 by Stefan Krause - http://www.stefan
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Beta
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*	XP Look and Feel														   *
*															                   *
*  (C) Copyright 2002, by Stefan Krause, Taufik Romdhane and Contributors      *
*                                                                              *
*                                                                              *
* The XP Look and Feel started as as extension to the Metouia Look and Feel.   *
* The original header of this file was:                                        *
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*        Metouia Look And Feel: a free pluggable look and feel for java        *
*                         http://mlf.sourceforge.net                           *
*          (C) Copyright 2002, by Taoufik Romdhane and Contributors.           *
*                                                                              *
*   This library is free software; you can redistribute it and/or modify it    *
*   under the terms of the GNU Lesser General Public License as published by   *
*   the Free Software Foundation; either version 2.1 of the License, or (at    *
*   your option) any later version.                                            *
*                                                                              *
*   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 General Public License along    *
*   with this program; if not, write to the Free Software Foundation, Inc.,   *
*   59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.                    *
*                                                                              *
*   Original Author:  Taoufik Romdhane                                         *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


package com.stefankrause.xplookandfeel;

import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.Insets;

import javax.swing.ImageIcon;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.basic.BasicBorders;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.MetalTheme;

import com.stefankrause.xplookandfeel.borders.XPPopupMenuBorder;
import com.stefankrause.xplookandfeel.borders.XPTextFieldBorder;
import com.stefankrause.xplookandfeel.skin.SkinImageCache;

/**
 * The XP look and feel. There's a special property to switch the support for
 * rounded windows of internal frames on or off:
 * Use xplookandfeel.roundedWindows = false to turn this support off. It causes
 * slower rendering especially in the case of dragging the internal frame. 
 * By default it is tuned on. 
 *
 * @author Taoufik Romdhane, Stefan Krause
 */
public class XPLookAndFeel extends MetalLookAndFeel
{
  /**
   * The current Metouia compatible theme.
   */
  protected static XPDefaultTheme xpTheme;

  /**
   * The installation state of the Metouia Look and Feel.
   */
  private static boolean isInstalled = false;

  /**
   * The installation state of the Metouia Theme.
   */
  private static boolean themeHasBeenSet = false;

  /**
   * This constructor installs the Metouia Look and Feel with the default color
   * theme.
   */
  public XPLookAndFeel()
  {
	String roundedWindows=System.getProperty("xplookandfeel.roundedWindows");
	if (roundedWindows!=null && roundedWindows.equals("false") )
	{
		XPInternalFrameUI.allowRoundedWindows=false;	
	}
	
    if (!isInstalled)
    {
      isInstalled = true;
      UIManager.installLookAndFeel(
        new UIManager.LookAndFeelInfo(
          "XPLookAndFeel",
          "com.stefankrause.xplookandfeel.XPLookAndFeel"));
    }
  }

  /**
   * Return a string that identifies this look and feel.  This string
   * will be used by applications/services that want to recognize
   * well known look and feel implementations.  Presently
   * the well known names are "Motif", "Windows", "Mac", "Metal".  Note
   * that a LookAndFeel derived from a well known superclass
   * that doesn't make any fundamental changes to the look or feel
   * shouldn't override this method.
   *
   * @return The Metouia Look and Feel identifier.
   */
  public String getID()
  {
    return "XPLookAndFeel";
  }

  /**
   * Return a short string that identifies this look and feel, e.g.
   * "CDE/Motif".  This string should be appropriate for a menu item.
   * Distinct look and feels should have different names, e.g.
   * a subclass of MotifLookAndFeel that changes the way a few components
   * are rendered should be called "CDE/Motif My Way"; something
   * that would be useful to a user trying to select a L&F from a list
   * of names.
   *
   * @return The look and feel short name.
   */
  public String getName()
  {
    return "XPLookAndFeel";
  }

  /**
   * Return a one line description of this look and feel implementation,
   * e.g. "The CDE/Motif Look and Feel".   This string is intended for
   * the user, e.g. in the title of a window or in a ToolTip message.
   *
   * @return The look and feel short description.
   */
  public String getDescription()
  {
    return "XPLookAndFeel: A faked luna look and feel.";
  }

  /**
   * If the underlying platform has a "native" look and feel, and this
   * is an implementation of it, return true.  For example a CDE/Motif
   * look and implementation would return true when the underlying
   * platform was Solaris.
   */
  public boolean isNativeLookAndFeel()
  {
    return true;
  }

  /**
   * Return true if the underlying platform supports and or permits
   * this look and feel.  This method returns false if the look
   * and feel depends on special resources or legal agreements that
   * aren't defined for the current platform.
   */
  public final boolean isSupportedLookAndFeel()
  {
  	String osName=(String)(System.getProperty("os.name") );
  	/*
  	 *******************************************
  	 * Creacked by BeanSoft Studio at 2003.2.14.
  	 * Then this L&F can run on any OS.
  	 *******************************************
  	 */
    // return osName.equals("Windows XP");
    return true;
  }

  /**
   * Initializes the uiClassID to BasicComponentUI mapping.
   * The JComponent classes define their own uiClassID constants. This table
   * must map those constants to a BasicComponentUI class of the appropriate
   * type.
   *
   * @param table The ui defaults table.
   */
  protected void initClassDefaults(UIDefaults table)
  {
    super.initClassDefaults(table);
    table.putDefaults(new Object[]
    {
      "ButtonUI", "com.stefankrause.xplookandfeel.XPButtonUI",
      "CheckBoxUI", "com.stefankrause.xplookandfeel.XPCheckBoxUI",
      "TextFieldUI", "com.stefankrause.xplookandfeel.XPTextFieldUI",
      "FormattedTextFieldUI", "com.stefankrause.xplookandfeel.XPTextFieldUI",
      "SliderUI", "com.stefankrause.xplookandfeel.XPSliderUI",
      "SpinnerUI", "com.stefankrause.xplookandfeel.XPSpinnerUI",
      "ToolBarUI", "com.stefankrause.xplookandfeel.XPToolBarUI",
      "MenuBarUI", "com.stefankrause.xplookandfeel.XPMenuBarUI",
      "MenuUI", "com.stefankrause.xplookandfeel.XPMenuUI",
      "MenuItemUI", "com.stefankrause.xplookandfeel.XPMenuItemUI",
 	  "CheckBoxMenuItemUI", "com.stefankrause.xplookandfeel.XPCheckBoxMenuItemUI",
      "RadioButtonMenuItemUI", "com.stefankrause.xplookandfeel.XPRadioButtonMenuItemUI",

      "ScrollBarUI", "com.stefankrause.xplookandfeel.XPScrollBarUI",
      "TabbedPaneUI", "com.stefankrause.xplookandfeel.XPTabbedPaneUI",
      "ToggleButtonUI", "com.stefankrause.xplookandfeel.XPButtonUI",
      "ScrollPaneUI", "com.stefankrause.xplookandfeel.XPScrollPaneUI",
      "ProgressBarUI", "com.stefankrause.xplookandfeel.XPProgressBarUI",
      "InternalFrameUI", "com.stefankrause.xplookandfeel.XPInternalFrameUI",
      "RadioButtonUI", "com.stefankrause.xplookandfeel.XPRadioButtonUI",
      "ComboBoxUI", "com.stefankrause.xplookandfeel.XPComboBoxUI",
      "PopupMenuSeparatorUI","com.stefankrause.xplookandfeel.XPPopupMenuSeparatorUI",
      "SplitPaneUI","com.stefankrause.xplookandfeel.XPSplitPaneUI",
      "FileChooserUI", "com.stefankrause.xplookandfeel.XPFileChooserUI",
    });
  }

  /**
   * Creates the default theme and installs it.
   * The XPDefaultTheme is used as default.
   */
  protected void createDefaultTheme()
  {
    if (!themeHasBeenSet)
    {
      xpTheme = new XPDefaultTheme();
      setCurrentTheme(xpTheme);
    }
  }

⌨️ 快捷键说明

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