home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / IBM VisualAge for Java Enterprise v4.0 Retail / ivj40 / setup / IDE.Cab / F76732_BasicStatusComboBoxButton.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-04-25  |  3.5 KB  |  109 lines

  1. package com.ibm.ivb.jface.basic;
  2.  
  3. import com.ibm.ivb.jface.parts.StatusButton;
  4. import com.ibm.ivb.jface.parts.StatusComboBox;
  5. import java.awt.Component;
  6. import java.awt.Graphics;
  7. import java.awt.Insets;
  8. import javax.swing.AbstractButton;
  9. import javax.swing.CellRendererPane;
  10. import javax.swing.Icon;
  11. import javax.swing.JComboBox;
  12. import javax.swing.JComponent;
  13. import javax.swing.JList;
  14. import javax.swing.ListCellRenderer;
  15.  
  16. public class BasicStatusComboBoxButton extends StatusButton {
  17.    private static final String kCBIBMCopyright = "(c) Copyright IBM Corporation 1998";
  18.    protected JComboBox comboBox;
  19.    protected JList listBox;
  20.    protected CellRendererPane rendererPane;
  21.    protected Icon comboIcon;
  22.    protected boolean iconOnly;
  23.  
  24.    BasicStatusComboBoxButton() {
  25.       super("");
  26.       this.iconOnly = false;
  27.       1 var1 = new 1();
  28.       ((AbstractButton)this).setHorizontalAlignment(2);
  29.       ((AbstractButton)this).setModel(var1);
  30.    }
  31.  
  32.    public BasicStatusComboBoxButton(JComboBox var1, Icon var2, CellRendererPane var3, JList var4) {
  33.       this();
  34.       this.comboBox = var1;
  35.       this.comboIcon = var2;
  36.       this.rendererPane = var3;
  37.       this.listBox = var4;
  38.    }
  39.  
  40.    public BasicStatusComboBoxButton(JComboBox var1, Icon var2, boolean var3, CellRendererPane var4, JList var5) {
  41.       this(var1, var2, var4, var5);
  42.       this.iconOnly = var3;
  43.    }
  44.  
  45.    public final JComboBox getComboBox() {
  46.       return this.comboBox;
  47.    }
  48.  
  49.    public final Icon getComboIcon() {
  50.       return this.comboIcon;
  51.    }
  52.  
  53.    public final boolean isIconOnly() {
  54.       return this.iconOnly;
  55.    }
  56.  
  57.    public void paintComponent(Graphics var1) {
  58.       super.paintComponent(var1);
  59.       Insets var2 = ((JComponent)this).getInsets();
  60.       int var3 = ((JComponent)this).getWidth() - (var2.left + var2.right);
  61.       int var4 = ((JComponent)this).getHeight() - (var2.top + var2.bottom);
  62.       int var5 = var2.left;
  63.       int var6 = var2.top;
  64.       int var7 = var5 + (var3 - 1);
  65.       int var8 = 0;
  66.       boolean var10 = ((AbstractButton)this).getModel().isPressed();
  67.       boolean var11 = this.comboBox instanceof StatusComboBox ? ((StatusComboBox)this.comboBox).isDirectTextEnabled() : false;
  68.       int var12 = var10 ? 1 : 0;
  69.       if (this.comboIcon != null) {
  70.          var8 = this.comboIcon.getIconWidth();
  71.          int var13 = this.comboIcon.getIconHeight();
  72.          int var14 = 0;
  73.          int var9;
  74.          if (this.iconOnly) {
  75.             var9 = ((JComponent)this).getWidth() / 2 - var8 / 2;
  76.             var14 = ((JComponent)this).getHeight() / 2 - var13 / 2;
  77.          } else {
  78.             var9 = var7 - var8 + 2;
  79.             var14 = var6 + 4;
  80.          }
  81.  
  82.          this.comboIcon.paintIcon(this, var1, var9 + var12, var14 + var12);
  83.       }
  84.  
  85.       if (!this.iconOnly && this.comboBox != null && !var11) {
  86.          ListCellRenderer var16 = this.comboBox.getRenderer();
  87.          Component var18 = var16.getListCellRendererComponent(this.listBox, this.comboBox.getSelectedItem(), -1, var10, false);
  88.          var18.setFont(this.rendererPane.getFont());
  89.          var18.setBackground(this.comboBox.getBackground());
  90.          var18.setForeground(this.comboBox.getForeground());
  91.          int var15 = var3 - (var2.right + var8);
  92.          this.rendererPane.paintComponent(var1, var18, this, var5 + var12, var6 + var12, var15, var4);
  93.       }
  94.  
  95.    }
  96.  
  97.    public final void setComboBox(JComboBox var1) {
  98.       this.comboBox = var1;
  99.    }
  100.  
  101.    public final void setComboIcon(Icon var1) {
  102.       this.comboIcon = var1;
  103.    }
  104.  
  105.    public final void setIconOnly(boolean var1) {
  106.       this.iconOnly = var1;
  107.    }
  108. }
  109.