home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / JToolBar.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  5.8 KB  |  246 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dimension;
  6. import java.awt.Graphics;
  7. import java.awt.Insets;
  8. import java.beans.PropertyChangeListener;
  9. import java.io.IOException;
  10. import java.io.ObjectOutputStream;
  11. import javax.accessibility.Accessible;
  12. import javax.accessibility.AccessibleContext;
  13. import javax.swing.plaf.ToolBarUI;
  14.  
  15. public class JToolBar extends JComponent implements SwingConstants, Accessible {
  16.    private static final String uiClassID = "ToolBarUI";
  17.    private boolean paintBorder;
  18.    private Insets margin;
  19.    private boolean floatable;
  20.    private int orientation;
  21.  
  22.    public JToolBar() {
  23.       this(0);
  24.    }
  25.  
  26.    public JToolBar(int var1) {
  27.       this((String)null, var1);
  28.    }
  29.  
  30.    public JToolBar(String var1) {
  31.       this(var1, 0);
  32.    }
  33.  
  34.    public JToolBar(String var1, int var2) {
  35.       this.paintBorder = true;
  36.       this.margin = null;
  37.       this.floatable = true;
  38.       this.orientation = 0;
  39.       ((Component)this).setName(var1);
  40.       this.checkOrientation(var2);
  41.       this.orientation = var2;
  42.       if (var2 == 1) {
  43.          ((Container)this).setLayout(new BoxLayout(this, 1));
  44.       } else if (SwingUtilities.isLeftToRight(this)) {
  45.          ((Container)this).setLayout(new BoxLayout(this, 0));
  46.       } else {
  47.          ((Container)this).setLayout(new RightToLeftToolBarLayout((1)null));
  48.       }
  49.  
  50.       ((JComponent)this).addPropertyChangeListener(new PropertyChangeHandler(this, (1)null));
  51.       this.updateUI();
  52.    }
  53.  
  54.    public ToolBarUI getUI() {
  55.       return (ToolBarUI)super.ui;
  56.    }
  57.  
  58.    public void setUI(ToolBarUI var1) {
  59.       super.setUI(var1);
  60.    }
  61.  
  62.    public void updateUI() {
  63.       this.setUI((ToolBarUI)UIManager.getUI(this));
  64.       ((Container)this).invalidate();
  65.    }
  66.  
  67.    public String getUIClassID() {
  68.       return "ToolBarUI";
  69.    }
  70.  
  71.    public int getComponentIndex(Component var1) {
  72.       int var2 = ((Container)this).getComponentCount();
  73.       Component[] var3 = ((Container)this).getComponents();
  74.  
  75.       for(int var4 = 0; var4 < var2; ++var4) {
  76.          Component var5 = var3[var4];
  77.          if (var5 == var1) {
  78.             return var4;
  79.          }
  80.       }
  81.  
  82.       return -1;
  83.    }
  84.  
  85.    public Component getComponentAtIndex(int var1) {
  86.       int var2 = ((Container)this).getComponentCount();
  87.       if (var1 >= 0 && var1 < var2) {
  88.          Component[] var3 = ((Container)this).getComponents();
  89.          return var3[var1];
  90.       } else {
  91.          return null;
  92.       }
  93.    }
  94.  
  95.    public void setMargin(Insets var1) {
  96.       Insets var2 = this.margin;
  97.       this.margin = var1;
  98.       ((JComponent)this).firePropertyChange("margin", var2, var1);
  99.       ((JComponent)this).revalidate();
  100.       ((Component)this).repaint();
  101.    }
  102.  
  103.    public Insets getMargin() {
  104.       return this.margin == null ? new Insets(0, 0, 0, 0) : this.margin;
  105.    }
  106.  
  107.    public boolean isBorderPainted() {
  108.       return this.paintBorder;
  109.    }
  110.  
  111.    public void setBorderPainted(boolean var1) {
  112.       if (this.paintBorder != var1) {
  113.          boolean var2 = this.paintBorder;
  114.          this.paintBorder = var1;
  115.          ((JComponent)this).firePropertyChange("borderPainted", var2, var1);
  116.          ((JComponent)this).revalidate();
  117.          ((Component)this).repaint();
  118.       }
  119.  
  120.    }
  121.  
  122.    protected void paintBorder(Graphics var1) {
  123.       if (this.isBorderPainted()) {
  124.          super.paintBorder(var1);
  125.       }
  126.  
  127.    }
  128.  
  129.    public boolean isFloatable() {
  130.       return this.floatable;
  131.    }
  132.  
  133.    public void setFloatable(boolean var1) {
  134.       if (this.floatable != var1) {
  135.          boolean var2 = this.floatable;
  136.          this.floatable = var1;
  137.          ((JComponent)this).firePropertyChange("floatable", var2, var1);
  138.          ((JComponent)this).revalidate();
  139.          ((Component)this).repaint();
  140.       }
  141.  
  142.    }
  143.  
  144.    public int getOrientation() {
  145.       return this.orientation;
  146.    }
  147.  
  148.    public void setOrientation(int var1) {
  149.       this.checkOrientation(var1);
  150.       if (this.orientation != var1) {
  151.          int var2 = this.orientation;
  152.          this.orientation = var1;
  153.          if (var1 == 1) {
  154.             ((Container)this).setLayout(new BoxLayout(this, 1));
  155.          } else if (SwingUtilities.isLeftToRight(this)) {
  156.             ((Container)this).setLayout(new BoxLayout(this, 0));
  157.          } else {
  158.             ((Container)this).setLayout(new RightToLeftToolBarLayout((1)null));
  159.          }
  160.  
  161.          ((JComponent)this).firePropertyChange("orientation", var2, var1);
  162.          ((JComponent)this).revalidate();
  163.          ((Component)this).repaint();
  164.       }
  165.  
  166.    }
  167.  
  168.    private void checkOrientation(int var1) {
  169.       switch (var1) {
  170.          case 0:
  171.          case 1:
  172.             return;
  173.          default:
  174.             throw new IllegalArgumentException("orientation must be one of: VERTICAL, HORIZONTAL");
  175.       }
  176.    }
  177.  
  178.    public void addSeparator() {
  179.       Separator var1 = new Separator();
  180.       ((Container)this).add(var1);
  181.    }
  182.  
  183.    public void addSeparator(Dimension var1) {
  184.       Separator var2 = new Separator(var1);
  185.       ((Container)this).add(var2);
  186.    }
  187.  
  188.    public JButton add(Action var1) {
  189.       JButton var2 = this.createActionComponent(var1);
  190.       ((AbstractButton)var2).setAction(var1);
  191.       ((Container)this).add(var2);
  192.       return var2;
  193.    }
  194.  
  195.    protected JButton createActionComponent(Action var1) {
  196.       String var2 = (String)var1.getValue("Name");
  197.       Icon var3 = (Icon)var1.getValue("SmallIcon");
  198.       1 var4 = new 1(this, var2, var3);
  199.       if (var3 != null) {
  200.          ((JComponent)var4).putClientProperty("hideActionText", Boolean.TRUE);
  201.       }
  202.  
  203.       ((AbstractButton)var4).setHorizontalTextPosition(0);
  204.       ((AbstractButton)var4).setVerticalTextPosition(3);
  205.       ((AbstractButton)var4).setEnabled(var1.isEnabled());
  206.       ((JComponent)var4).setToolTipText((String)var1.getValue("ShortDescription"));
  207.       return var4;
  208.    }
  209.  
  210.    protected PropertyChangeListener createActionChangeListener(JButton var1) {
  211.       return null;
  212.    }
  213.  
  214.    protected void addImpl(Component var1, Object var2, int var3) {
  215.       super.addImpl(var1, var2, var3);
  216.       if (var1 instanceof JButton) {
  217.          ((JButton)var1).setDefaultCapable(false);
  218.       }
  219.  
  220.    }
  221.  
  222.    private void writeObject(ObjectOutputStream var1) throws IOException {
  223.       var1.defaultWriteObject();
  224.       if (super.ui != null && this.getUIClassID().equals("ToolBarUI")) {
  225.          super.ui.installUI(this);
  226.       }
  227.  
  228.    }
  229.  
  230.    protected String paramString() {
  231.       String var1 = this.paintBorder ? "true" : "false";
  232.       String var2 = this.margin != null ? this.margin.toString() : "";
  233.       String var3 = this.floatable ? "true" : "false";
  234.       String var4 = this.orientation == 0 ? "HORIZONTAL" : "VERTICAL";
  235.       return super.paramString() + ",floatable=" + var3 + ",margin=" + var2 + ",orientation=" + var4 + ",paintBorder=" + var1;
  236.    }
  237.  
  238.    public AccessibleContext getAccessibleContext() {
  239.       if (super.accessibleContext == null) {
  240.          super.accessibleContext = new AccessibleJToolBar(this);
  241.       }
  242.  
  243.       return super.accessibleContext;
  244.    }
  245. }
  246.