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

📄 infonodelookandfeel.java

📁 修正了jdk1.6中对托盘事件产生异常的bug.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * Copyright (C) 2004 NNL Technology AB
 * Visit www.infonode.net for information about InfoNode(R) 
 * products and how to contact NNL Technology AB.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program 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 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.
 */

// $Id: InfoNodeLookAndFeel.java,v 1.22 2005/12/04 13:46:03 jesper Exp $
package net.infonode.gui.laf;

import net.infonode.gui.icon.button.TreeIcon;
import net.infonode.gui.laf.ui.SlimComboBoxUI;
import net.infonode.gui.laf.ui.SlimInternalFrameUI;
import net.infonode.gui.laf.ui.SlimMenuItemUI;
import net.infonode.gui.laf.ui.SlimSplitPaneUI;
import net.infonode.util.ArrayUtil;
import net.infonode.util.ColorUtil;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalBorders;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.MetalTheme;
import java.awt.*;
import java.lang.reflect.InvocationTargetException;

/**
 * A Look and Feel that's based on Metal. It's slimmer and use other colors than the standard Metal Look and Feel.
 * Under Java 1.5 the currect Metal theme is stored when the InfoNode Look and Feel is applied, and restored when
 * another Look and Feel is set. Under Java 1.4 or earlier it is not possible to get the current theme and a
 * DefaultMetalTheme is set instead.
 * <p>
 * To set the look and feel use:
 * <pre>
 * UIManager.setLookAndFeel(new InfoNodeLookAndFeel());
 * </pre>
 * Or, if you want to use a different theme, use:
 * <pre>
 * InfoNodeLookAndFeelTheme theme = new InfoNodeLookAndFeelTheme(...);
 * // Modify the theme colors, fonts etc.
 * UIManager.setLookAndFeel(new InfoNodeLookAndFeel(theme));
 * </pre>
 * Do not modify the theme after it has been used in the look and feel!
 *
 * @author $Author: jesper $
 * @version $Revision: 1.22 $
 */
public class InfoNodeLookAndFeel extends MetalLookAndFeel {
  public static final UIManager.LookAndFeelInfo LOOK_AND_FEEL_INFO =
      new UIManager.LookAndFeelInfo("InfoNode", InfoNodeLookAndFeel.class.getName());

  private static MetalTheme oldMetalTheme;

  private transient InfoNodeLookAndFeelTheme theme;

  private transient DefaultMetalTheme defaultTheme = new DefaultMetalTheme() {
    public ColorUIResource getPrimaryControlHighlight() {
      return theme.getPrimaryControlHighlightColor();
    }

    public ColorUIResource getMenuBackground() {
      return theme.getControlColor();
    }

    public ColorUIResource getControlHighlight() {
      return theme.getControlHighlightColor();
    }

    public ColorUIResource getControl() {
      return theme.getControlColor();
    }

    public ColorUIResource getControlShadow() {
      return theme.getControlShadowColor();
    }

    public ColorUIResource getControlDarkShadow() {
      return theme.getControlDarkShadowColor();
    }

    // Scrollbars, popups etc.
    public ColorUIResource getPrimaryControl() {
      return theme.getPrimaryControlColor();
    }

    public ColorUIResource getPrimaryControlShadow() {
      return theme.getPrimaryControlShadowColor();
    }

    public ColorUIResource getPrimaryControlDarkShadow() {
      return theme.getPrimaryControlDarkShadowColor();
    }
    // End scrollbars

    public ColorUIResource getTextHighlightColor() {
      return theme.getSelectedTextBackgroundColor();
    }

    public ColorUIResource getMenuSelectedBackground() {
      return theme.getSelectedMenuBackgroundColor();
    }

    public ColorUIResource getWindowBackground() {
      return theme.getBackgroundColor();
    }

    protected ColorUIResource getWhite() {
      return theme.getBackgroundColor();
    }

    public ColorUIResource getDesktopColor() {
      return theme.getDesktopColor();
    }

    public ColorUIResource getHighlightedTextColor() {
      return theme.getSelectedTextColor();
    }

    protected ColorUIResource getBlack() {
      return theme.getTextColor();
    }

    public ColorUIResource getMenuForeground() {
      return theme.getTextColor();
    }

    public ColorUIResource getMenuSelectedForeground() {
      return theme.getSelectedMenuForegroundColor();
    }

    public ColorUIResource getFocusColor() {
      return theme.getFocusColor();
    }

    public ColorUIResource getControlDisabled() {
      return theme.getControlColor();
    }

    public ColorUIResource getSystemTextColor() {
      return theme.getTextColor();
    }

    public ColorUIResource getControlTextColor() {
      return theme.getTextColor();
    }

    public ColorUIResource getInactiveControlTextColor() {
      return theme.getInactiveTextColor();
    }

    public ColorUIResource getInactiveSystemTextColor() {
      return theme.getInactiveTextColor();
    }

    public ColorUIResource getUserTextColor() {
      return theme.getTextColor();
    }


    // --------------- Fonts --------------------------

    public FontUIResource getControlTextFont() {
      return getSystemTextFont();
    }

    public FontUIResource getSystemTextFont() {
      return theme.getFont();
    }

    public FontUIResource getUserTextFont() {
      return getSystemTextFont();
    }

    public FontUIResource getMenuTextFont() {
      return getSystemTextFont();
    }

    public FontUIResource getWindowTitleFont() {
      return getSystemTextFont();
    }

    public FontUIResource getSubTextFont() {
      return getSystemTextFont();
    }

  };

  /**
   * Constructor.
   */
  public InfoNodeLookAndFeel() {
    this(new InfoNodeLookAndFeelTheme());
  }

  /**
   * Constructor.
   *
   * @param theme the theme to use. Do not modify the theme after this constructor has been called!
   */
  public InfoNodeLookAndFeel(InfoNodeLookAndFeelTheme theme) {
    this.theme = theme;
  }

  /**
   * Gets the active theme
   *
   * @return the active theme

⌨️ 快捷键说明

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