Ejemplo n.º 1
0
 @Override
 public Component getListCellRendererComponent(
     JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) {
   label.setText(Objects.toString(value, ""));
   this.list = list;
   this.index = index;
   if (isSelected) {
     setBackground(list.getSelectionBackground());
     label.setForeground(list.getSelectionForeground());
   } else {
     setBackground(index % 2 == 0 ? EVEN_COLOR : list.getBackground());
     label.setForeground(list.getForeground());
   }
   MutableComboBoxModel m = (MutableComboBoxModel) list.getModel();
   if (index < 0 || m.getSize() - 1 <= 0) {
     setOpaque(false);
     deleteButton.setVisible(false);
     label.setForeground(list.getForeground());
   } else {
     boolean f = index == rolloverIndex;
     setOpaque(true);
     deleteButton.setVisible(true);
     deleteButton.getModel().setRollover(f);
     deleteButton.setForeground(f ? Color.WHITE : list.getForeground());
   }
   return this;
 }
Ejemplo n.º 2
0
 public void showDialog() {
   statusBar.setText(" ");
   setVisible(true);
   try {
     // Bring to front of other dialogs
     setSelected(true);
   } catch (PropertyVetoException e) {
     // ignore
   }
 }
Ejemplo n.º 3
0
 void browse(String urlStr) {
   try {
     Desktop.getDesktop().browse(new URI(urlStr));
   } catch (Exception ex) {
     showDialog();
     statusBar.setText(ex.getLocalizedMessage());
     if (JConsole.isDebug()) {
       ex.printStackTrace();
     }
   }
 }
Ejemplo n.º 4
0
 public ButtonsRenderer(RemoveButtonComboBox<E> comboBox) {
   super(new BorderLayout(0, 0));
   this.comboBox = comboBox;
   label.setOpaque(false);
   setOpaque(true);
   add(label);
   deleteButton.setBorder(BorderFactory.createEmptyBorder());
   deleteButton.setFocusable(false);
   deleteButton.setRolloverEnabled(false);
   deleteButton.setContentAreaFilled(false);
   add(deleteButton, BorderLayout.EAST);
 }
Ejemplo n.º 5
0
  /**
   * {@inheritDoc}
   *
   * @since 1.7
   */
  public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
    if (!isShowing()) {
      return false;
    }

    // Check that there is a label with such image
    Enumeration elements = labelTable.elements();

    while (elements.hasMoreElements()) {
      Component component = (Component) elements.nextElement();

      if (component instanceof JLabel) {
        JLabel label = (JLabel) component;

        if (SwingUtilities.doesIconReferenceImage(label.getIcon(), img)
            || SwingUtilities.doesIconReferenceImage(label.getDisabledIcon(), img)) {
          return super.imageUpdate(img, infoflags, x, y, w, h);
        }
      }
    }

    return false;
  }
Ejemplo n.º 6
0
 public void loadImage(String filename) {
   theImage.setIcon(new MyImageIcon(filename));
 }