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

📄 closetabbedpaneui.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * CloseTabbedPaneUI.java * * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis * * 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 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. * */package org.underworldlabs.swing.plaf;import java.awt.Color;import java.awt.Component;import java.awt.Container;import java.awt.Dimension;import java.awt.Event;import java.awt.Font;import java.awt.FontMetrics;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Insets;import java.awt.LayoutManager;import java.awt.Point;import java.awt.Polygon;import java.awt.Rectangle;import java.awt.Shape;//import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ContainerEvent;import java.awt.event.ContainerListener;import java.awt.event.FocusAdapter;import java.awt.event.FocusEvent;import java.awt.event.FocusListener;import java.awt.event.MouseEvent;import java.awt.event.MouseListener;import java.awt.event.MouseMotionListener;import java.beans.PropertyChangeEvent;import java.beans.PropertyChangeListener;import java.util.Hashtable;import java.util.Vector;import javax.swing.AbstractAction;import javax.swing.ActionMap;import javax.swing.Icon;import javax.swing.InputMap;import javax.swing.JComponent;import javax.swing.JPanel;import javax.swing.JTabbedPane;import javax.swing.JViewport;import javax.swing.KeyStroke;import javax.swing.LookAndFeel;import javax.swing.SwingConstants;import javax.swing.SwingUtilities;import javax.swing.UIManager;import javax.swing.event.ChangeEvent;import javax.swing.event.ChangeListener;import javax.swing.plaf.ActionMapUIResource;import javax.swing.plaf.ComponentUI;import javax.swing.plaf.InputMapUIResource;import javax.swing.plaf.UIResource;import javax.swing.plaf.basic.BasicArrowButton;import javax.swing.plaf.basic.BasicGraphicsUtils;import javax.swing.plaf.basic.BasicHTML;import javax.swing.plaf.basic.BasicTabbedPaneUI;import javax.swing.text.View;import org.underworldlabs.swing.SimpleCloseTabbedPane;import org.underworldlabs.swing.CloseTabbedPane;//import org.executequery.util.IconUtilities;/* * @(#)CloseTabbedPaneUI.java	1.126 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. *//* ---------------------------------------------------------- * CVS NOTE: Changes to the CVS repository prior to the  *           release of version 3.0.0beta1 has meant a  *           resetting of CVS revision numbers. * ---------------------------------------------------------- *//** This is a slight modification to the original BasicTabbedPaneUI. *  It removes the heavy border and makes the selected tab bg white. *  This is the beginning of a larger modification - at the moment it *  really is purpose built for the nav panel and its white content panels *  and gray lines. *//** * * @author   Takis Diakoumis * @version  $Revision: 1.5 $ * @date     $Date: 2006/07/15 10:32:09 $ */public class CloseTabbedPaneUI extends BasicTabbedPaneUI                               implements SwingConstants {            // Instance variables initialized at installation        protected JTabbedPane tabPane;        protected Color highlight;    protected Color lightHighlight;    protected Color shadow;    protected Color darkShadow;    protected Color focus;        private Color activeColor;    private Color unselectedBackground;    private Color controlShadow;    //private Color unselectedBackground;        protected int textIconGap;        protected int tabRunOverlay;        protected Insets tabInsets;    protected Insets selectedTabPadInsets;    protected Insets tabAreaInsets;    protected Insets contentBorderInsets;        // Transient variables (recalculated each time TabbedPane is layed out)        protected int tabRuns[] = new int[10];    protected int runCount = 0;    protected int selectedRun = -1;    protected Rectangle rects[] = new Rectangle[0];    protected int maxTabHeight;    protected int maxTabWidth;        // Listeners        /*    protected ChangeListener tabChangeListener;    protected PropertyChangeListener propertyChangeListener;    protected MouseListener mouseListener;    protected FocusListener focusListener;     */    // PENDING(api): See comment for ContainerHandler    private   ContainerListener containerListener;        // Private instance data        private Insets currentPadInsets = new Insets(0,0,0,0);    private Insets currentTabAreaInsets = new Insets(0,0,0,0);        private Component visibleComponent;    // PENDING(api): See comment for ContainerHandler    private Vector htmlViews;        private Hashtable mnemonicToIndexMap;        /**     * InputMap used for mnemonics. Only non-null if the JTabbedPane has     * mnemonics associated with it. Lazily created in initMnemonics.     */    private InputMap mnemonicInputMap;        // For use when tabLayoutPolicy = SCROLL_TAB_LAYOUT    private ScrollableTabSupport tabScroller;        /**     * A rectangle used for general layout calculations in order     * to avoid constructing many new Rectangles on the fly.     */    protected transient Rectangle calcRect = new Rectangle(0,0,0,0);        /**     * Number of tabs. When the count differs, the mnemonics are updated.     */    // PENDING: This wouldn't be necessary if JTabbedPane had a better    // way of notifying listeners when the count changed.    private int tabCount;        // UI creation        public static ComponentUI createUI(JComponent c) {        return new CloseTabbedPaneUI();    }        // UI Installation/De-installation        public void installUI(JComponent c) {        this.tabPane = (JTabbedPane)c;                c.setLayout(createLayoutManager());        installComponents();        installDefaults();        installListeners();        installKeyboardActions();    }        public void uninstallUI(JComponent c) {        //System.out.println("XX");        uninstallKeyboardActions();        uninstallListeners();        uninstallDefaults();        uninstallComponents();        c.setLayout(null);                this.tabPane = null;    }        /**     * Invoked by <code>installUI</code> to create     * a layout manager object to manage     * the <code>JTabbedPane</code>.     *     * @return a layout manager object     *     * @see TabbedPaneLayout     * @see javax.swing.JTabbedPane#getTabLayoutPolicy     */    protected LayoutManager createLayoutManager() {        if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) {            return new TabbedPaneScrollLayout();        } else { /* WRAP_TAB_LAYOUT */            return new TabbedPaneLayout();        }    }        /* In an attempt to preserve backward compatibility for programs     * which have extended CloseTabbedPaneUI to do their own layout, the     * UI uses the installed layoutManager (and not tabLayoutPolicy) to     * determine if scrollTabLayout is enabled.     */    private boolean scrollableTabLayoutEnabled() {        return true;        //return (tabPane.getLayout() instanceof TabbedPaneScrollLayout);    }        /**     * Creates and installs any required subcomponents for the JTabbedPane.     * Invoked by installUI.     *     * @since 1.4     */    protected void installComponents() {        if (scrollableTabLayoutEnabled()) {            if (tabScroller == null) {                tabScroller = new ScrollableTabSupport(tabPane.getTabPlacement());                tabPane.add(tabScroller.viewport);                tabPane.add(tabScroller.scrollForwardButton);                tabPane.add(tabScroller.scrollBackwardButton);            }        }    }        /**     * Removes any installed subcomponents from the JTabbedPane.     * Invoked by uninstallUI.     *     * @since 1.4     */    protected void uninstallComponents() {        if (scrollableTabLayoutEnabled()) {            tabPane.remove(tabScroller.viewport);            tabPane.remove(tabScroller.scrollForwardButton);            tabPane.remove(tabScroller.scrollBackwardButton);            tabScroller = null;        }    }        protected void installDefaults() {        LookAndFeel.installColorsAndFont(tabPane, "TabbedPane.background",                "TabbedPane.foreground", "TabbedPane.font");        highlight = UIManager.getColor("TabbedPane.light");        lightHighlight = UIManager.getColor("TabbedPane.highlight");        shadow = UIManager.getColor("TabbedPane.shadow");        darkShadow = UIManager.getColor("TabbedPane.darkShadow");        focus = UIManager.getColor("TabbedPane.focus");        controlShadow = UIManager.getColor("controlShadow");                activeColor = UIManager.getColor("TabbedPane.selected");        if (activeColor == null) {            activeColor = UIManager.getColor("TabbedPane.background");                        if (activeColor == null) { // if still null (some l&f)                activeColor = UIManager.getColor("control");            }        }        unselectedBackground = UIManager.getColor("TabbedPane.unselectedBackground");        if (unselectedBackground == null) {            unselectedBackground = UIManager.getColor("TabbedPane.unselectedTabBackground");                        if (unselectedBackground == null) { // if still null (some l&f)                unselectedBackground = UIManager.getColor("controlLightShadow");                if (unselectedBackground == null) { // if still null - give up                    unselectedBackground = tabPane.getBackground().darker();                }            }                    }        // make the selected colour a little darker        //unselectedBackground = unselectedBackground.darker();                textIconGap = 2;        //textIconGap = UIManager.getInt("TabbedPane.textIconGap");        tabInsets = UIManager.getInsets("TabbedPane.tabInsets");                selectedTabPadInsets = UIManager.getInsets("TabbedPane.selectedTabPadInsets");        tabAreaInsets = new Insets(2,0,0,6);        //tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets");                contentBorderInsets = new Insets(1,1,1,1);        //contentBorderInsets = UIManager.getInsets("TabbedPane.contentBorderInsets");        tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay");            }        protected void uninstallDefaults() {        highlight = null;        lightHighlight = null;        shadow = null;        darkShadow = null;        focus = null;        tabInsets = null;        selectedTabPadInsets = null;        tabAreaInsets = null;        contentBorderInsets = null;    }    private Handler handler = new Handler();        protected void installListeners() {        if ((propertyChangeListener = createPropertyChangeListener()) != null) {            tabPane.addPropertyChangeListener(propertyChangeListener);        }        if ((tabChangeListener = createChangeListener()) != null) {            tabPane.addChangeListener(tabChangeListener);        }        if ((mouseListener = createMouseListener()) != null) {            if (scrollableTabLayoutEnabled()) {                tabScroller.tabPanel.addMouseListener(mouseListener);                tabScroller.tabPanel.addMouseMotionListener((MouseMotionListener)mouseListener);            } else { // WRAP_TAB_LAYOUT                tabPane.addMouseListener(mouseListener);            }        }        if ((focusListener = createFocusListener()) != null) {            tabPane.addFocusListener(focusListener);        }        // PENDING(api) : See comment for ContainerHandler        if ((containerListener = new ContainerHandler()) != null) {            tabPane.addContainerListener(containerListener);            if (tabPane.getTabCount()>0) {                htmlViews = createHTMLVector();

⌨️ 快捷键说明

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