home *** CD-ROM | disk | FTP | other *** search
/ Australian PC Authority 1999 May / may1999.iso / May / JBUILDER / JSAMPLES.Z / ComboBoxPanel$TestCellRenderer.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-30  |  1.9 KB  |  54 lines

  1. import com.sun.java.swing.Icon;
  2. import com.sun.java.swing.ImageIcon;
  3. import com.sun.java.swing.JComboBox;
  4. import com.sun.java.swing.JComponent;
  5. import com.sun.java.swing.JLabel;
  6. import com.sun.java.swing.JList;
  7. import com.sun.java.swing.ListCellRenderer;
  8. import com.sun.java.swing.UIManager;
  9. import java.awt.Component;
  10. import java.util.Hashtable;
  11.  
  12. class ComboBoxPanel$TestCellRenderer extends JLabel implements ListCellRenderer {
  13.    // $FF: synthetic field
  14.    private final ComboBoxPanel this$0;
  15.    JComboBox combobox;
  16.  
  17.    public ComboBoxPanel$TestCellRenderer(ComboBoxPanel var1, JComboBox var2) {
  18.       this.this$0 = var1;
  19.       this.this$0 = var1;
  20.       this.combobox = var2;
  21.       ((JComponent)this).setOpaque(true);
  22.    }
  23.  
  24.    public Component getListCellRendererComponent(JList var1, Object var2, int var3, boolean var4, boolean var5) {
  25.       Hashtable var6 = (Hashtable)var2;
  26.       if (UIManager.getLookAndFeel().getName().equals("CDE/Motif")) {
  27.          if (var3 == -1) {
  28.             ((JComponent)this).setOpaque(false);
  29.          } else {
  30.             ((JComponent)this).setOpaque(true);
  31.          }
  32.       } else {
  33.          ((JComponent)this).setOpaque(true);
  34.       }
  35.  
  36.       if (var2 == null) {
  37.          ((JLabel)this).setText("");
  38.          ((JLabel)this).setIcon((Icon)null);
  39.       } else if (var4) {
  40.          ((Component)this).setBackground(UIManager.getColor("ComboBox.selectedBackground"));
  41.          ((Component)this).setForeground(UIManager.getColor("ComboBox.selectedForeground"));
  42.          ((JLabel)this).setIcon((ImageIcon)var6.get("Himage"));
  43.          ((JLabel)this).setText((String)var6.get("title"));
  44.       } else {
  45.          ((JLabel)this).setIcon((ImageIcon)var6.get("image"));
  46.          ((JLabel)this).setText((String)var6.get("title"));
  47.          ((Component)this).setBackground(UIManager.getColor("ComboBox.background"));
  48.          ((Component)this).setForeground(UIManager.getColor("ComboBox.foreground"));
  49.       }
  50.  
  51.       return this;
  52.    }
  53. }
  54.