home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / jfc.bin / BasicEditorPaneUI.java < prev    next >
Text File  |  1998-02-26  |  4KB  |  125 lines

  1. /*
  2.  * @(#)BasicEditorPaneUI.java    1.13 98/02/02
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20. package com.sun.java.swing.plaf.basic;
  21.  
  22. import java.awt.*;
  23. import java.awt.event.*;
  24. import java.beans.*;
  25. import java.net.URL;
  26. import java.net.MalformedURLException;
  27. import com.sun.java.swing.*;
  28. import com.sun.java.swing.text.*;
  29. import com.sun.java.swing.plaf.*;
  30. import com.sun.java.swing.border.*;
  31.  
  32.  
  33. /**
  34.  * Provides the look and feel for an html text editor.
  35.  * <p>
  36.  * Warning: serialized objects of this class will not be compatible with
  37.  * future swing releases.  The current serialization support is appropriate 
  38.  * for short term storage or RMI between Swing1.0 applications.  It will
  39.  * not be possible to load serialized Swing1.0 objects with future releases
  40.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  41.  * baseline for the serialized form of Swing objects.
  42.  *
  43.  * @author  Timothy Prinzing
  44.  * @version 1.13 02/02/98
  45.  */
  46. public class BasicEditorPaneUI extends BasicTextPaneUI {
  47.  
  48.     /**
  49.      * Creates a UI for the JTextPane.
  50.      *
  51.      * @param c the JTextPane component
  52.      * @return the UI
  53.      */
  54.     public static ComponentUI createUI(JComponent c) {
  55.         return new BasicEditorPaneUI();
  56.     }
  57.  
  58.     /**
  59.      * Creates a new BasicEditorPaneUI.
  60.      */
  61.     public BasicEditorPaneUI() {
  62.     super();
  63.     }
  64.  
  65.     /**
  66.      * Fetches the name used as a key to lookup properties through the
  67.      * UIManager.  This is used as a prefix to all the standard
  68.      * text properties.
  69.      *
  70.      * @return the name
  71.      */
  72.     protected String getPropertyPrefix() {
  73.     return "EditorPane";
  74.     }
  75.  
  76.     /**
  77.      * Fetches the EditorKit for the UI.  This is whatever is
  78.      * currently set in the associated JEditorPane.
  79.      *
  80.      * @return the editor capabilities
  81.      * @see TextUI#getEditorKit
  82.      */
  83.     public EditorKit getEditorKit() {
  84.     JEditorPane pane = (JEditorPane) getComponent();
  85.     return pane.getEditorKit();
  86.     }
  87.  
  88.     /**
  89.      * The name of the default keymap that will be shared 
  90.      * by all BasicEditorPaneUI instances unless they arrange for something
  91.      * different.  The keymap will resolve through the
  92.      * JTextController.DEFAULT_KEYMAP.
  93.      */
  94.     public static final String KeymapName = "BasicEditorPane";
  95.  
  96.     /**
  97.      * Default bindings for the default keymap if no other bindings
  98.      * are given.  
  99.      */
  100.     static final JTextComponent.KeyBinding[] defaultBindings = {
  101.     new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_C, 
  102.                                    InputEvent.CTRL_MASK),
  103.                        DefaultEditorKit.copyAction),
  104.     new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V, 
  105.                                    InputEvent.CTRL_MASK),
  106.                        DefaultEditorKit.pasteAction),
  107.     new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_X, 
  108.                                    InputEvent.CTRL_MASK),
  109.                        DefaultEditorKit.cutAction),
  110.     new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
  111.                        DefaultEditorKit.pageUpAction),
  112.     new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
  113.                        DefaultEditorKit.pageDownAction),
  114.     new JTextComponent.KeyBinding(KeyStroke.getKeyStroke('\n'),
  115.                        DefaultEditorKit.insertBreakAction),
  116.     new JTextComponent.KeyBinding(KeyStroke.getKeyStroke('\r'),
  117.                        DefaultEditorKit.insertBreakAction)
  118.     };
  119.  
  120.     static Keymap defaultKeymap = null;
  121.  
  122. }
  123.  
  124.  
  125.