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$LogicalStyleAction.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-26  |  1.8 KB  |  35 lines

  1. package com.sun.java.swing.text.html;
  2.  
  3. import com.sun.java.swing.JEditorPane;
  4. import com.sun.java.swing.text.JTextComponent;
  5. import com.sun.java.swing.text.Style;
  6. import com.sun.java.swing.text.StyledDocument;
  7. import com.sun.java.swing.text.TextAction;
  8. import java.awt.event.ActionEvent;
  9.  
  10. class HTMLEditorKit$LogicalStyleAction extends HTMLEditorKit.HtmlAction {
  11.    String styleStr;
  12.  
  13.    HTMLEditorKit$LogicalStyleAction(String var1) {
  14.       super("html-logical-style-action");
  15.       this.styleStr = var1;
  16.    }
  17.  
  18.    public void actionPerformed(ActionEvent var1) {
  19.       JEditorPane var2 = (JEditorPane)((TextAction)this).getFocusedComponent();
  20.       if (var2 != null) {
  21.          StyledDocument var3 = (StyledDocument)((JTextComponent)var2).getDocument();
  22.          Style var4 = var3.getStyle(this.styleStr);
  23.          if (var4 != null) {
  24.             var3.setLogicalStyle(((JTextComponent)var2).getCaretPosition(), var4);
  25.          }
  26.       }
  27.  
  28.    }
  29.  
  30.    public void setLogicalStyle(Object var1, String var2) {
  31.       this.styleStr = var2;
  32.       this.actionPerformed(new ActionEvent(var1, 0, "html-logical-style"));
  33.    }
  34. }
  35.