home *** CD-ROM | disk | FTP | other *** search
- package com.ibm.ivb.jface.basic;
-
- import com.ibm.ivb.jface.parts.StatusButton;
- import com.ibm.ivb.jface.parts.StatusComboBox;
- import java.awt.Component;
- import java.awt.Graphics;
- import java.awt.Insets;
- import javax.swing.AbstractButton;
- import javax.swing.CellRendererPane;
- import javax.swing.Icon;
- import javax.swing.JComboBox;
- import javax.swing.JComponent;
- import javax.swing.JList;
- import javax.swing.ListCellRenderer;
-
- public class BasicStatusComboBoxButton extends StatusButton {
- private static final String kCBIBMCopyright = "(c) Copyright IBM Corporation 1998";
- protected JComboBox comboBox;
- protected JList listBox;
- protected CellRendererPane rendererPane;
- protected Icon comboIcon;
- protected boolean iconOnly;
-
- BasicStatusComboBoxButton() {
- super("");
- this.iconOnly = false;
- 1 var1 = new 1();
- ((AbstractButton)this).setHorizontalAlignment(2);
- ((AbstractButton)this).setModel(var1);
- }
-
- public BasicStatusComboBoxButton(JComboBox var1, Icon var2, CellRendererPane var3, JList var4) {
- this();
- this.comboBox = var1;
- this.comboIcon = var2;
- this.rendererPane = var3;
- this.listBox = var4;
- }
-
- public BasicStatusComboBoxButton(JComboBox var1, Icon var2, boolean var3, CellRendererPane var4, JList var5) {
- this(var1, var2, var4, var5);
- this.iconOnly = var3;
- }
-
- public final JComboBox getComboBox() {
- return this.comboBox;
- }
-
- public final Icon getComboIcon() {
- return this.comboIcon;
- }
-
- public final boolean isIconOnly() {
- return this.iconOnly;
- }
-
- public void paintComponent(Graphics var1) {
- super.paintComponent(var1);
- Insets var2 = ((JComponent)this).getInsets();
- int var3 = ((JComponent)this).getWidth() - (var2.left + var2.right);
- int var4 = ((JComponent)this).getHeight() - (var2.top + var2.bottom);
- int var5 = var2.left;
- int var6 = var2.top;
- int var7 = var5 + (var3 - 1);
- int var8 = 0;
- boolean var10 = ((AbstractButton)this).getModel().isPressed();
- boolean var11 = this.comboBox instanceof StatusComboBox ? ((StatusComboBox)this.comboBox).isDirectTextEnabled() : false;
- int var12 = var10 ? 1 : 0;
- if (this.comboIcon != null) {
- var8 = this.comboIcon.getIconWidth();
- int var13 = this.comboIcon.getIconHeight();
- int var14 = 0;
- int var9;
- if (this.iconOnly) {
- var9 = ((JComponent)this).getWidth() / 2 - var8 / 2;
- var14 = ((JComponent)this).getHeight() / 2 - var13 / 2;
- } else {
- var9 = var7 - var8 + 2;
- var14 = var6 + 4;
- }
-
- this.comboIcon.paintIcon(this, var1, var9 + var12, var14 + var12);
- }
-
- if (!this.iconOnly && this.comboBox != null && !var11) {
- ListCellRenderer var16 = this.comboBox.getRenderer();
- Component var18 = var16.getListCellRendererComponent(this.listBox, this.comboBox.getSelectedItem(), -1, var10, false);
- var18.setFont(this.rendererPane.getFont());
- var18.setBackground(this.comboBox.getBackground());
- var18.setForeground(this.comboBox.getForeground());
- int var15 = var3 - (var2.right + var8);
- this.rendererPane.paintComponent(var1, var18, this, var5 + var12, var6 + var12, var15, var4);
- }
-
- }
-
- public final void setComboBox(JComboBox var1) {
- this.comboBox = var1;
- }
-
- public final void setComboIcon(Icon var1) {
- this.comboIcon = var1;
- }
-
- public final void setIconOnly(boolean var1) {
- this.iconOnly = var1;
- }
- }
-