home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 144 / DPCS0200.iso / Internet / Supanet / system / swing.jar / javax / swing / text / StyledEditorKit.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-05  |  4.1 KB  |  56 lines

  1. package javax.swing.text;
  2.  
  3. import javax.swing.Action;
  4. import javax.swing.JEditorPane;
  5. import javax.swing.event.CaretListener;
  6.  
  7. public class StyledEditorKit extends DefaultEditorKit {
  8.    private static final ViewFactory defaultFactory = new StyledViewFactory();
  9.    Element currentRun;
  10.    Element currentParagraph;
  11.    MutableAttributeSet inputAttributes = new 1(this);
  12.    private CaretListener inputAttributeUpdater = new AttributeTracker(this);
  13.    private static final Action[] defaultActions = new Action[]{new FontFamilyAction("font-family-SansSerif", "SansSerif"), new FontFamilyAction("font-family-Monospaced", "Monospaced"), new FontFamilyAction("font-family-Serif", "Serif"), new FontSizeAction("font-size-8", 8), new FontSizeAction("font-size-10", 10), new FontSizeAction("font-size-12", 12), new FontSizeAction("font-size-14", 14), new FontSizeAction("font-size-16", 16), new FontSizeAction("font-size-18", 18), new FontSizeAction("font-size-24", 24), new FontSizeAction("font-size-36", 36), new FontSizeAction("font-size-48", 48), new AlignmentAction("left-justify", 0), new AlignmentAction("center-justify", 1), new AlignmentAction("right-justify", 2), new BoldAction(), new ItalicAction(), new UnderlineAction()};
  14.  
  15.    public Object clone() {
  16.       return new StyledEditorKit();
  17.    }
  18.  
  19.    public Document createDefaultDocument() {
  20.       return new DefaultStyledDocument();
  21.    }
  22.  
  23.    protected void createInputAttributes(Element var1, MutableAttributeSet var2) {
  24.       var2.removeAttributes(var2);
  25.       var2.addAttributes(var1.getAttributes());
  26.       var2.removeAttribute(StyleConstants.ComponentAttribute);
  27.       var2.removeAttribute(StyleConstants.IconAttribute);
  28.       var2.removeAttribute("$ename");
  29.       var2.removeAttribute(StyleConstants.ComposedTextAttribute);
  30.    }
  31.  
  32.    public void deinstall(JEditorPane var1) {
  33.       ((JTextComponent)var1).removeCaretListener(this.inputAttributeUpdater);
  34.    }
  35.  
  36.    public Action[] getActions() {
  37.       return TextAction.augmentList(super.getActions(), defaultActions);
  38.    }
  39.  
  40.    public Element getCharacterAttributeRun() {
  41.       return this.currentRun;
  42.    }
  43.  
  44.    public MutableAttributeSet getInputAttributes() {
  45.       return this.inputAttributes;
  46.    }
  47.  
  48.    public ViewFactory getViewFactory() {
  49.       return defaultFactory;
  50.    }
  51.  
  52.    public void install(JEditorPane var1) {
  53.       ((JTextComponent)var1).addCaretListener(this.inputAttributeUpdater);
  54.    }
  55. }
  56.