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

  1. package com.sun.java.swing.text.html;
  2.  
  3. import com.sun.java.swing.JEditorPane;
  4. import com.sun.java.swing.text.MutableAttributeSet;
  5. import com.sun.java.swing.text.StyleConstants;
  6. import com.sun.java.swing.text.StyledEditorKit;
  7. import com.sun.java.swing.text.TextAction;
  8. import java.awt.event.ActionEvent;
  9.  
  10. class HTMLEditorKit$ParagraphIndentAction extends HTMLEditorKit.HtmlAction {
  11.    boolean bLeft = false;
  12.  
  13.    HTMLEditorKit$ParagraphIndentAction(String var1, boolean var2) {
  14.       super(var1);
  15.       this.bLeft = var2;
  16.    }
  17.  
  18.    public void actionPerformed(ActionEvent var1) {
  19.       JEditorPane var2 = (JEditorPane)((TextAction)this).getFocusedComponent();
  20.       if (var2 != null) {
  21.          StyledEditorKit var3 = ((StyledEditorKit.StyledTextAction)this).getStyledEditorKit(var2);
  22.          MutableAttributeSet var4 = var3.getInputAttributes();
  23.          if (var4 != null) {
  24.             int var5 = StyleConstants.getAlignment(var4);
  25.             if (!this.bLeft) {
  26.                if (var5 == 0) {
  27.                   var5 = 1;
  28.                } else if (var5 == 1) {
  29.                   var5 = 2;
  30.                }
  31.             } else if (var5 == 1) {
  32.                var5 = 0;
  33.             } else if (var5 == 2) {
  34.                var5 = 1;
  35.             }
  36.  
  37.             StyleConstants.setAlignment(var4, var5);
  38.             ((StyledEditorKit.StyledTextAction)this).setParagraphAttributes(var2, var4, false);
  39.          }
  40.       }
  41.  
  42.    }
  43. }
  44.