jtabbedpane.java
来自「Mac OS X 10.4.9 for x86 Source Code gcc」· Java 代码 · 共 1,477 行 · 第 1/3 页
JAVA
1,477 行
/* JTabbedPane.java -- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING. If not, write to theFree Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library. Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule. An independent module is a module which is not derived fromor based on this library. If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so. If you do not wish to do so, delete thisexception statement from your version. */package javax.swing;import java.awt.Color;import java.awt.Component;import java.awt.Point;import java.awt.Rectangle;import java.awt.event.MouseEvent;import java.io.Serializable;import java.util.Vector;import javax.accessibility.Accessible;import javax.accessibility.AccessibleContext;import javax.accessibility.AccessibleRole;import javax.accessibility.AccessibleSelection;import javax.swing.event.ChangeEvent;import javax.swing.event.ChangeListener;import javax.swing.plaf.TabbedPaneUI;import javax.swing.plaf.UIResource;/** * This is a container for components. One component is displayed at a time. * Users can switch between components by clicking on tabs. * * <p> * Tabs can be oriented in several ways. They can be above, below, left and * right of the component. Tabs can either wrap around (by creating multiple * rows of tabs) or they can be scrolled (where only a subset of the tabs * can be seen at once). More tabs can be added by calling the * add/addTab/insertTab methods. * </p> */public class JTabbedPane extends JComponent implements Serializable, Accessible, SwingConstants{ /** * DOCUMENT ME! */ protected class AccessibleJTabbedPane extends JComponent.AccessibleJComponent implements AccessibleSelection, ChangeListener { /** DOCUMENT ME! */ private static final long serialVersionUID = 7610530885966830483L; /** * Creates a new AccessibleJTabbedPane object. */ public AccessibleJTabbedPane() { super(); } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void stateChanged(ChangeEvent e) { } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public AccessibleRole getAccessibleRole() { return null; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public int getAccessibleChildrenCount() { return 0; } /** * DOCUMENT ME! * * @param i DOCUMENT ME! * * @return DOCUMENT ME! */ public Accessible getAccessibleChild(int i) { return null; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public AccessibleSelection getAccessibleSelection() { return null; } /** * DOCUMENT ME! * * @param p DOCUMENT ME! * * @return DOCUMENT ME! */ public Accessible getAccessibleAt(Point p) { return null; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public int getAccessibleSelectionCount() { return 0; } /** * DOCUMENT ME! * * @param i DOCUMENT ME! * * @return DOCUMENT ME! */ public Accessible getAccessibleSelection(int i) { return null; } /** * DOCUMENT ME! * * @param i DOCUMENT ME! * * @return DOCUMENT ME! */ public boolean isAccessibleChildSelected(int i) { return false; } /** * DOCUMENT ME! * * @param i DOCUMENT ME! */ public void addAccessibleSelection(int i) { } /** * DOCUMENT ME! * * @param i DOCUMENT ME! */ public void removeAccessibleSelection(int i) { } /** * DOCUMENT ME! */ public void clearAccessibleSelection() { } /** * DOCUMENT ME! */ public void selectAllAccessibleSelection() { } } /** * A helper class that listens for changes to the model. */ protected class ModelListener implements ChangeListener, Serializable { /** DOCUMENT ME! */ private static final long serialVersionUID = 497359819958114132L; /** * Creates a new ModelListener object. */ protected ModelListener() { } /** * This method is called whenever the model is changed. * * @param e The ChangeEvent that is passed from the model. */ public void stateChanged(ChangeEvent e) { // Propagate to our listeners. fireStateChanged(); } } /** * A private class that holds all the information for each tab. */ private class Page { /** The tooltip string. */ private String tip; /** The component associated with the tab. */ private Component component; /** The active icon associated with the tab. */ private transient Icon icon; /** The disabled icon associated with the tab. */ private transient Icon disabledIcon; /** The tab's enabled status. */ private transient boolean enabled = true; /** The string painted on the tab. */ private transient String title; /** The background color of the tab. */ private transient Color bg; /** The foreground color of the tab. */ private transient Color fg; /** The mnemonic associated with the tab. */ private transient int mnemonicKey; /** The index of the underlined character in the string. */ private transient int underlinedChar = -1; /** * Creates a new data storage for the tab. * * @param title The string displayed on the tab. * @param icon The active icon displayed on the tab. * @param component The component associated with the tab. * @param tip The tooltip associated with the tab. */ protected Page(String title, Icon icon, Component component, String tip) { this.title = title; this.icon = icon; this.component = component; this.tip = tip; } /** * This method returns the component associated with the tab. * * @return The component associated with the tab. */ public Component getComponent() { return component; } /** * This method sets the component associated with the tab. * * @param c The component associated with the tab. */ public void setComponent(Component c) { remove(component); this.component = c; add(c); } /** * This method returns the tooltip string. * * @return The tooltip string. */ public String getTip() { return tip; } /** * This method sets the tooltip string. * * @param tip The tooltip string. */ public void setTip(String tip) { this.tip = tip; } /** * This method returns the background color. * * @return The background color. */ public Color getBackground() { return bg; } /** * This method sets the background color. * * @param background The background color. */ public void setBackground(Color background) { bg = background; } /** * This method returns the foreground color. * * @return The foreground color. */ public Color getForeground() { return fg; } /** * This method sets the foreground color. * * @param foreground The foreground color. */ public void setForeground(Color foreground) { fg = foreground; } /** * This method returns the title associated with the tab. * * @return The title of the tab. */ public String getTitle() { return title; } /** DOCUMENT ME! */ private static final long serialVersionUID = 1614381073220130939L; /** * This method sets the title of the tab. * * @param text The title of the tab. */ public void setTitle(String text) { title = text; if (title != null && title.length() <= underlinedChar) setDisplayedMnemonicIndex(title.length() - 1); } /** * This method returns the active icon. * * @return The active icon. */ public Icon getIcon() { return icon; } /** * This method sets the active icon. * * @param icon The active icon. */ public void setIcon(Icon icon) { this.icon = icon; } /** * This method returns the disabled icon. * * @return The disabled icon. */ public Icon getDisabledIcon() { if (disabledIcon == null && icon instanceof ImageIcon) setDisabledIcon(icon); return disabledIcon; } /** * This method sets the disabled icon. * * @param disabledIcon The disabled icon. */ public void setDisabledIcon(Icon disabledIcon) { this.disabledIcon = disabledIcon; } /** * This method returns whether the tab is enabled. * * @return Whether the tab is enabled. */ public boolean isEnabled() { return enabled; } /** * This method sets whether the tab is enabled. * * @param enabled Whether this tab is enabled. */ public void setEnabled(boolean enabled) { this.enabled = enabled; } /** * This method returns the mnemonic. * * @return The mnemonic. */ public int getMnemonic() { return (int) mnemonicKey; } /** * This method sets the mnemonic. If the title is set, it will update the * mnemonicIndex. * * @param key The mnemonic. */ public void setMnemonic(int key) { setMnemonic((char) key); } /** * This method sets the mnemonic. If the title is set, it will update the * mnemonicIndex. * * @param aChar The mnemonic.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?