home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / copyjava.exe / com / sun / java / swing / text / StyledEditorKit.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-26  |  3.8 KB  |  46 lines

  1. package com.sun.java.swing.text;
  2.  
  3. import com.sun.java.swing.Action;
  4. import com.sun.java.swing.JEditorPane;
  5.  
  6. public class StyledEditorKit extends DefaultEditorKit {
  7.    private static final ViewFactory defaultFactory = new StyledViewFactory();
  8.    Element currentRun;
  9.    Element currentParagraph;
  10.    MutableAttributeSet inputAttributes = new 1(this);
  11.    private AttributeTracker caretHandler = new AttributeTracker(this);
  12.    private static final Action[] defaultActions = new Action[]{new FontFamilyAction("font-family-Helvetica", "Helvetica"), new FontFamilyAction("font-family-Courier", "Courier"), new FontFamilyAction("font-family-TimesRoman", "TimesRoman"), 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()};
  13.  
  14.    public MutableAttributeSet getInputAttributes() {
  15.       return this.inputAttributes;
  16.    }
  17.  
  18.    public Element getCharacterAttributeRun() {
  19.       return this.currentRun;
  20.    }
  21.  
  22.    public Object clone() {
  23.       return new StyledEditorKit();
  24.    }
  25.  
  26.    public Action[] getActions() {
  27.       return TextAction.augmentList(super.getActions(), defaultActions);
  28.    }
  29.  
  30.    public Document createDefaultDocument() {
  31.       return new DefaultStyledDocument();
  32.    }
  33.  
  34.    public void install(JEditorPane var1) {
  35.       ((JTextComponent)var1).addCaretListener(this.caretHandler);
  36.    }
  37.  
  38.    public void deinstall(JEditorPane var1) {
  39.       ((JTextComponent)var1).removeCaretListener(this.caretHandler);
  40.    }
  41.  
  42.    public ViewFactory getViewFactory() {
  43.       return defaultFactory;
  44.    }
  45. }
  46.