Ejemplo n.º 1
0
    /* This is the only method defined by ListCellRenderer.  We just
     * reconfigure the Jlabel each time we're called.
     */
    public Component getListCellRendererComponent(
        JList list,
        Object value, // value to display
        int index, // cell index
        boolean iss, // is the cell selected
        boolean chf) // the list and the cell have the focus
        {
      /* The DefaultListCellRenderer class will take care of
       * the JLabels text property, it's foreground and background
       * colors, and so on.
       */
      super.getListCellRendererComponent(list, value, index, iss, chf);
      if (afks.contains(value.toString())) {
        setIcon(afk);
      } else if (admins.contains(value.toString())) {
        setIcon(admin);
      } else if (ignores.contains(value.toString())) {
        setIcon(ignored);
      } else {
        setIcon(normal);
      }
      if (username.equals(getText())) {
        setForeground(myColors[1]);
      } else {
        setForeground(myColors[2]);
      }

      return this;
    }
Ejemplo n.º 2
0
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

      IconListEntry icon = (IconListEntry) value;
      setIcon(icon.icon);

      return this;
    }