< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java

Print this page




  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.swing.plaf.basic;
  27 
  28 import java.awt.Font;
  29 import java.awt.Color;
  30 import java.awt.SystemColor;
  31 import java.awt.event.*;
  32 import java.awt.Insets;
  33 import java.awt.Component;
  34 import java.awt.Container;
  35 import java.awt.FocusTraversalPolicy;
  36 import java.awt.AWTEvent;
  37 import java.awt.Toolkit;
  38 import java.awt.Point;
  39 import java.net.URL;
  40 import java.io.*;
  41 import java.awt.Dimension;
  42 import java.awt.KeyboardFocusManager;

  43 import java.security.AccessController;
  44 import java.security.PrivilegedAction;
  45 import java.util.*;
  46 import java.lang.reflect.*;
  47 import javax.sound.sampled.*;
  48 
  49 import sun.awt.AppContext;
  50 import sun.awt.SunToolkit;
  51 
  52 import sun.swing.SwingUtilities2;
  53 import sun.swing.icon.SortArrowIcon;
  54 
  55 import javax.swing.LookAndFeel;
  56 import javax.swing.AbstractAction;
  57 import javax.swing.Action;
  58 import javax.swing.ActionMap;
  59 import javax.swing.BorderFactory;
  60 import javax.swing.JComponent;
  61 import javax.swing.ImageIcon;
  62 import javax.swing.UIDefaults;
  63 import javax.swing.UIManager;
  64 import javax.swing.KeyStroke;
  65 import javax.swing.JTextField;
  66 import javax.swing.DefaultListCellRenderer;
  67 import javax.swing.FocusManager;
  68 import javax.swing.LayoutFocusTraversalPolicy;
  69 import javax.swing.SwingUtilities;
  70 import javax.swing.MenuSelectionManager;
  71 import javax.swing.MenuElement;
  72 import javax.swing.border.*;
  73 import javax.swing.plaf.*;
  74 import javax.swing.text.JTextComponent;
  75 import javax.swing.text.DefaultEditorKit;
  76 import javax.swing.JInternalFrame;
  77 import static javax.swing.UIDefaults.LazyValue;

  78 import java.beans.PropertyVetoException;
  79 import java.awt.Window;
  80 import java.beans.PropertyChangeListener;
  81 import java.beans.PropertyChangeEvent;
  82 
  83 
  84 /**
  85  * A base class to use in creating a look and feel for Swing.
  86  * <p>
  87  * Each of the {@code ComponentUI}s provided by {@code
  88  * BasicLookAndFeel} derives its behavior from the defaults
  89  * table. Unless otherwise noted each of the {@code ComponentUI}
  90  * implementations in this package document the set of defaults they
  91  * use. Unless otherwise noted the defaults are installed at the time
  92  * {@code installUI} is invoked, and follow the recommendations
  93  * outlined in {@code LookAndFeel} for installing defaults.
  94  * <p>
  95  * <strong>Warning:</strong>
  96  * Serialized objects of this class will not be compatible with
  97  * future Swing releases. The current serialization support is


1824             "Tree.ancestorInputMap",
1825                new UIDefaults.LazyInputMap(new Object[] {
1826                      "ESCAPE", "cancel"
1827                  }),
1828             // Bind specific keys that can invoke popup on currently
1829             // focused JComponent
1830             "RootPane.ancestorInputMap",
1831                 new UIDefaults.LazyInputMap(new Object[] {
1832                      "shift F10", "postPopup",
1833                   "CONTEXT_MENU", "postPopup"
1834                   }),
1835 
1836             // These bindings are only enabled when there is a default
1837             // button set on the rootpane.
1838             "RootPane.defaultButtonWindowKeyBindings", new Object[] {
1839                              "ENTER", "press",
1840                     "released ENTER", "release",
1841                         "ctrl ENTER", "press",
1842                "ctrl released ENTER", "release"
1843               },

1844         };
1845 
1846         table.putDefaults(defaults);
1847     }
1848 
1849     static int getFocusAcceleratorKeyMask() {
1850         Toolkit tk = Toolkit.getDefaultToolkit();
1851         if (tk instanceof SunToolkit) {
1852             return ((SunToolkit)tk).getFocusAcceleratorKeyMask();
1853         }
1854         return ActionEvent.ALT_MASK;
1855     }
1856 
1857 
1858 
1859     /**
1860      * Returns the ui that is of type <code>klass</code>, or null if
1861      * one can not be found.
1862      */
1863     static Object getUIOfType(ComponentUI ui, Class<?> klass) {




  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.swing.plaf.basic;
  27 
  28 import java.awt.Font;
  29 import java.awt.Color;
  30 import java.awt.SystemColor;
  31 import java.awt.event.*;

  32 import java.awt.Component;


  33 import java.awt.AWTEvent;
  34 import java.awt.Toolkit;
  35 import java.awt.Point;

  36 import java.io.*;
  37 import java.awt.Dimension;
  38 import java.awt.FontMetrics;
  39 import java.awt.Graphics;
  40 import java.security.AccessController;
  41 import java.security.PrivilegedAction;
  42 import java.util.*;

  43 import javax.sound.sampled.*;
  44 
  45 import sun.awt.AppContext;
  46 import sun.awt.SunToolkit;
  47 
  48 import sun.swing.SwingUtilities2;
  49 import sun.swing.icon.SortArrowIcon;
  50 
  51 import javax.swing.LookAndFeel;
  52 import javax.swing.AbstractAction;
  53 import javax.swing.Action;
  54 import javax.swing.ActionMap;
  55 import javax.swing.BorderFactory;
  56 import javax.swing.JComponent;
  57 import javax.swing.ImageIcon;
  58 import javax.swing.UIDefaults;
  59 import javax.swing.UIManager;
  60 import javax.swing.KeyStroke;
  61 import javax.swing.JTextField;
  62 import javax.swing.DefaultListCellRenderer;
  63 import javax.swing.FocusManager;
  64 import javax.swing.LayoutFocusTraversalPolicy;
  65 import javax.swing.SwingUtilities;
  66 import javax.swing.MenuSelectionManager;
  67 import javax.swing.MenuElement;
  68 import javax.swing.border.*;
  69 import javax.swing.plaf.*;
  70 import javax.swing.text.JTextComponent;
  71 import javax.swing.text.DefaultEditorKit;
  72 import javax.swing.JInternalFrame;
  73 import static javax.swing.UIDefaults.LazyValue;
  74 //import javax.swing.plaf.
  75 import java.beans.PropertyVetoException;
  76 import java.awt.Window;
  77 import java.beans.PropertyChangeListener;
  78 import java.beans.PropertyChangeEvent;
  79 
  80 
  81 /**
  82  * A base class to use in creating a look and feel for Swing.
  83  * <p>
  84  * Each of the {@code ComponentUI}s provided by {@code
  85  * BasicLookAndFeel} derives its behavior from the defaults
  86  * table. Unless otherwise noted each of the {@code ComponentUI}
  87  * implementations in this package document the set of defaults they
  88  * use. Unless otherwise noted the defaults are installed at the time
  89  * {@code installUI} is invoked, and follow the recommendations
  90  * outlined in {@code LookAndFeel} for installing defaults.
  91  * <p>
  92  * <strong>Warning:</strong>
  93  * Serialized objects of this class will not be compatible with
  94  * future Swing releases. The current serialization support is


1821             "Tree.ancestorInputMap",
1822                new UIDefaults.LazyInputMap(new Object[] {
1823                      "ESCAPE", "cancel"
1824                  }),
1825             // Bind specific keys that can invoke popup on currently
1826             // focused JComponent
1827             "RootPane.ancestorInputMap",
1828                 new UIDefaults.LazyInputMap(new Object[] {
1829                      "shift F10", "postPopup",
1830                   "CONTEXT_MENU", "postPopup"
1831                   }),
1832 
1833             // These bindings are only enabled when there is a default
1834             // button set on the rootpane.
1835             "RootPane.defaultButtonWindowKeyBindings", new Object[] {
1836                              "ENTER", "press",
1837                     "released ENTER", "release",
1838                         "ctrl ENTER", "press",
1839                "ctrl released ENTER", "release"
1840               },
1841             "uiDrawing.text", SwingUtilities2.DEFAULT_UI_TEXT_DRAWING,
1842         };
1843 
1844         table.putDefaults(defaults);
1845     }
1846 
1847     static int getFocusAcceleratorKeyMask() {
1848         Toolkit tk = Toolkit.getDefaultToolkit();
1849         if (tk instanceof SunToolkit) {
1850             return ((SunToolkit)tk).getFocusAcceleratorKeyMask();
1851         }
1852         return ActionEvent.ALT_MASK;
1853     }
1854 
1855 
1856 
1857     /**
1858      * Returns the ui that is of type <code>klass</code>, or null if
1859      * one can not be found.
1860      */
1861     static Object getUIOfType(ComponentUI ui, Class<?> klass) {


< prev index next >