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

  1. package javax.swing.text;
  2.  
  3. import java.awt.Toolkit;
  4. import java.awt.event.ActionEvent;
  5. import java.util.EventObject;
  6. import javax.swing.JEditorPane;
  7.  
  8. public class StyledEditorKit$FontSizeAction extends StyledEditorKit.StyledTextAction {
  9.    private int size;
  10.  
  11.    public StyledEditorKit$FontSizeAction(String var1, int var2) {
  12.       super(var1);
  13.       this.size = var2;
  14.    }
  15.  
  16.    public void actionPerformed(ActionEvent var1) {
  17.       JEditorPane var2 = ((StyledEditorKit.StyledTextAction)this).getEditor(var1);
  18.       if (var2 != null) {
  19.          int var3 = this.size;
  20.          if (var1 != null && ((EventObject)var1).getSource() == var2) {
  21.             String var4 = var1.getActionCommand();
  22.  
  23.             try {
  24.                var3 = Integer.parseInt(var4, 10);
  25.             } catch (NumberFormatException var5) {
  26.             }
  27.          }
  28.  
  29.          if (var3 != 0) {
  30.             SimpleAttributeSet var6 = new SimpleAttributeSet();
  31.             StyleConstants.setFontSize(var6, var3);
  32.             ((StyledEditorKit.StyledTextAction)this).setCharacterAttributes(var2, var6, false);
  33.          } else {
  34.             Toolkit.getDefaultToolkit().beep();
  35.          }
  36.       }
  37.  
  38.    }
  39. }
  40.