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

📄 skinlookandfeel.java

📁 Skin Look And Feel 1.2.10, 给你的java程序换肤, 支持大量通用皮肤文件.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
 * ====================================================================
 * 
 * Skin Look And Feel 1.2.10 License.
 * 
 * Copyright (c) 2000-2004 L2FProd.com. All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met: 1.
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer. 2. Redistributions in
 * binary form must reproduce the above copyright notice, this list of
 * conditions and the following disclaimer in the documentation and/or other
 * materials provided with the distribution. 3. The end-user documentation
 * included with the redistribution, if any, must include the following
 * acknowlegement: "This product includes software developed by L2FProd.com
 * (http://www.L2FProd.com/)." Alternately, this acknowlegement may appear in
 * the software itself, if and wherever such third-party acknowlegements
 * normally appear. 4. The names "Skin Look And Feel", "SkinLF" and
 * "L2FProd.com" must not be used to endorse or promote products derived from
 * this software without prior written permission. For written permission,
 * please contact info@L2FProd.com. 5. Products derived from this software may
 * not be called "SkinLF" nor may "SkinLF" appear in their names without prior
 * written permission of L2FProd.com.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * L2FPROD.COM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * ====================================================================
 */
package com.l2fprod.gui.plaf.skin;

import com.l2fprod.contrib.nanoxml.XMLElement;
import com.l2fprod.gui.plaf.skin.impl.gtk.GtkSkin;
import com.l2fprod.gui.plaf.skin.impl.kde.KdeSkin;
import com.l2fprod.util.OS;
import com.l2fprod.util.StringUtils;
import com.l2fprod.util.ZipResourceLoader;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.KeyEvent;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.ResourceBundle;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.DimensionUIResource;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.basic.BasicLookAndFeel;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.JTextComponent;

/**
 * Skin Look And Feel Main Class. <br>Use this class to set the current skin
 * or to load skins. <br>See <a href="http://www.L2FProd.com/">L2FProd.com
 * website</a> for the complete description of a theme pack.
 * 
 * @author $Author: l2fprod $
 * @version $Revision: 1.14 $, $Date: 2004/08/13 19:26:21 $
 */
public class SkinLookAndFeel extends BasicLookAndFeel {

  /**
   * Description of the Field
   * 
   * @deprecated Will be soon replaced by {@link #version()}
   */
  public final static String VERSION = version();

  /**
   * Returns the Skin Look And Feel version
   * 
   * @return the Skin Look And Feel version
   */
  public static String version() {
    return "1.2.10";
  }

  public static String date() {
    return "08/13/2004 09:30 PM";
  }
  
  private static Skin c_CurrentSkin;
  private static ZipResourceLoader c_ResourceLoader;

  /**
   * Constructs a new SkinLookAndFeel
   */
  public SkinLookAndFeel() {
    UIManager.getLookAndFeelDefaults().put(
        "ClassLoader",
        getClass().getClassLoader());    
  }
  
  /**
   * Gets the Name attribute of the SkinLookAndFeel object
   * 
   * @return The Name value
   */
  public String getName() {
    return "SkinLF";
  }

  /**
   * Gets the Description attribute of the SkinLookAndFeel object
   * 
   * @return The Description value
   */
  public String getDescription() {
    return "Skin Look and Feel";
  }

  /**
   * Gets the ID attribute of the SkinLookAndFeel object
   * 
   * @return The ID value
   */
  public String getID() {
    return "SkinLF";
  }

  /**
   * Gets the NativeLookAndFeel attribute of the SkinLookAndFeel object
   * 
   * @return The NativeLookAndFeel value
   */
  public boolean isNativeLookAndFeel() {
    return false;
  }

  public boolean getSupportsWindowDecorations() {
    return true;
  }

  /**
   * Gets the SupportedLookAndFeel attribute of the SkinLookAndFeel object
   * 
   * @return The SupportedLookAndFeel value
   */
  public boolean isSupportedLookAndFeel() {
    return true;
  }

  /**
   * Description of the Method
   * 
   * @param table Description of Parameter
   */
  protected void initClassDefaults(UIDefaults table) {
    super.initClassDefaults(table);

    java.util.Vector list = new java.util.Vector();

    if (getSkin().getProgress() != null && getSkin().getProgress().status()) {
      list.addElement("ProgressBarUI");
      list.addElement(SkinProgressBarUI.class.getName());
    }

    if (getSkin().getTab() != null && getSkin().getTab().status()) {
      list.addElement("TabbedPaneUI");
      list.addElement(SkinTabbedPaneUI.class.getName());
    }

    if (getSkin().getFrame() != null && getSkin().getFrame().status()) {
      list.addElement("InternalFrameUI");
      list.addElement(SkinInternalFrameUI.class.getName());
      if (OS.isOneDotFourOrMore()) {
        // add support for decorated frames
        list.addElement("RootPaneUI");
        list.addElement(SkinRootPaneUI.class.getName());
      }
      list.addElement("WindowButtonUI");
      list.addElement(SkinWindowButtonUI.class.getName());
    }

    if (getSkin().getSlider() != null && getSkin().getSlider().status()) {
      list.addElement("SliderUI");
      list.addElement(SkinSliderUI.class.getName());
    }

    if (getSkin().getScrollbar() != null
      && getSkin().getScrollbar().status()) {
      list.addElement("ScrollBarUI");
      list.addElement(SkinScrollBarUI.class.getName());
    }

    if (getSkin().getButton() != null && getSkin().getButton().status()) {
      list.addElement("ButtonUI");
      list.addElement(SkinButtonUI.class.getName());
      list.addElement("ToggleButtonUI");
      list.addElement(SkinToggleButtonUI.class.getName());
    }

    if (getSkin().getSeparator() != null
      && getSkin().getSeparator().status()) {
      list.addElement("SeparatorUI");
      list.addElement(SkinSeparatorUI.class.getName());
    }

    Object[] uiDefaults =
      {
        "CheckBoxUI",
        SkinCheckBoxUI.class.getName(),
        "ComboBoxUI",
        SkinComboBoxUI.class.getName(),
        "CheckBoxMenuItemUI",
        SkinCheckBoxMenuItemUI.class.getName(),
        "MenuItemUI",
        SkinMenuItemUI.class.getName(),
        "MenuUI",
        SkinMenuUI.class.getName(),
        "MenuBarUI",
        SkinMenuBarUI.class.getName(),
        "ToolBarUI",
        SkinToolBarUI.class.getName(),
      //	    "ListUI", SkinListUI.class.getName(),
      "PopupMenuUI",
        SkinPopupMenuUI.class.getName(),
        "RadioButtonUI",
        SkinRadioButtonUI.class.getName(),
        "RadioButtonMenuItemUI",
        SkinRadioButtonMenuItemUI.class.getName(),
        "PanelUI",
        SkinPanelUI.class.getName(),
        "DesktopPaneUI",
        SkinDesktopPaneUI.class.getName(),
        "DesktopIconUI",
        SkinDesktopIconUI.class.getName(),
        "TableHeaderUI",
        SkinTableHeaderUI.class.getName(),
      // there is no basic filechooser ui!
      // so we use the filechooser from metal :(
        "FileChooserUI",
        SkinFileChooserUI.class.getName(),
        "TextFieldUI",
        "javax.swing.plaf.metal.MetalTextFieldUI",
        "SplitPaneUI",
        (Boolean.TRUE.equals(UIManager.get("JSplitPane.alternateUI"))
          ? (SkinSplitPaneUI.class.getName())
          : "javax.swing.plaf.basic.BasicSplitPaneUI"),
        "TreeUI",
        SkinTreeUI.class.getName(),
        "OptionPaneUI",
        SkinOptionPaneUI.class.getName(),
        "ToolTipUI",
        SkinToolTipUI.class.getName(),
        };
    for (int i = 0; i < uiDefaults.length; i++) {
      list.addElement(uiDefaults[i]);
    }

    Object[] results = new Object[list.size()];
    list.copyInto(results);
    table.putDefaults(results);
  }

  /**
   * Description of the Method
   * 
   * @param table Description of Parameter
   */
  protected void initSystemColorDefaults(UIDefaults table) {
    super.initSystemColorDefaults(table);

    String[] skinColors = getSkin().getColors();

    if (skinColors != null) {
      loadSystemColors(table, skinColors, isNativeLookAndFeel());
    } else {
      loadSystemColors(table, new String[0], isNativeLookAndFeel());
    }
  }

  /**
   * Description of the Method
   * 
   * @param table Description of Parameter
   */
  protected void initComponentDefaults(UIDefaults table) {
    super.initComponentDefaults(table);

    loadResourceBundle(table);

    // *** Tree
    Object treeExpandedIcon = SkinTreeUI.ExpandedIcon.createExpandedIcon();
    Object treeCollapsedIcon = SkinTreeUI.CollapsedIcon.createCollapsedIcon();

    Object checkIcon = new SkinCheckBoxIcon();

    Object[] defaults = {
      //  	    // Buttons
      "Button.dashedRectGapX",
        new Integer(5),
        "Button.dashedRectGapY",
        new Integer(4),
        "Button.dashedRectGapWidth",
        new Integer(10),
        "Button.dashedRectGapHeight",
        new Integer(8),
        "Button.textShiftOffset",
        new Integer(1),
        "Desktop.background",
        table.get("desktop"),
        "ToggleButton.textShiftOffset",
        new Integer(1),
        "CheckBoxMenuItem.checkIcon",
        checkIcon,
        "RadioButtonMenuItem.checkIcon",
        checkIcon,
        "SplitPane.dividerSize",
        new Integer(4),
        "SplitPane.background",
        table.get("control"),
        "ProgressBar.cellLength",
        new Integer(7),
        "ProgressBar.cellSpacing",
        new Integer(2),
        "Tree.expandedIcon",
        treeExpandedIcon,
        "Tree.collapsedIcon",
        treeCollapsedIcon,
        "Tree.line",
        Color.black,
      // horiz lines
      "Tree.hash", Color.black,
      // legs
      "Tree.rowHeight",
        new Integer(0),
        "Tree.textForeground",
        table.get("textText"),
        "Tree.textBackground",
        table.get("window"),
        "FileChooser.lookInLabelMnemonic",
        new Integer(KeyEvent.VK_I),
        "FileChooser.fileNameLabelMnemonic",
        new Integer(KeyEvent.VK_N),
        "FileChooser.filesOfTypeLabelMnemonic",
        new Integer(KeyEvent.VK_T),
        "InternalFrame.minimizeIconBackground",
        table.get("control"),
        "InternalFrame.resizeIconHighlight",
        table.get("controlHighlight"),
        "InternalFrame.resizeIconShadow",
        table.get("controlShadow"),
        };
    table.putDefaults(defaults);

    // bug fixed by Christopher R. Staley [Chris.Staley@itpwebsolutions.com]
    // for JDK1.3 we use InputMap and for JDK1.1,1.2 we use KeyBindings
    try {
      Class.forName("javax.swing.InputMap");
      Class uidefaults = Class.forName("javax.swing.UIDefaults");
      Class[] innerClasses = uidefaults.getClasses();
      java.lang.reflect.Constructor c = null;

      for (int i = 0; i < innerClasses.length; i++) {
        if (innerClasses[i].getName().endsWith("LazyInputMap")) {
          c = innerClasses[i].getConstructor(new Class[] { Object[].class });
          break;
        }
      }

      Object[] fieldInputMap =
        new Object[] {
          "ctrl C",
          DefaultEditorKit.copyAction,
          "ctrl V",
          DefaultEditorKit.pasteAction,
          "ctrl X",
          DefaultEditorKit.cutAction,
          "COPY",
          DefaultEditorKit.copyAction,
          "PASTE",
          DefaultEditorKit.pasteAction,
          "CUT",
          DefaultEditorKit.cutAction,
          "shift LEFT",
          DefaultEditorKit.selectionBackwardAction,
          "shift KP_LEFT",
          DefaultEditorKit.selectionBackwardAction,
          "shift RIGHT",
          DefaultEditorKit.selectionForwardAction,
          "shift KP_RIGHT",

⌨️ 快捷键说明

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