示例#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;
    }
示例#2
0
 @Override
 public Component getListCellRendererComponent(
     JList<? extends LogRecord> list,
     LogRecord record,
     int index,
     boolean isSelected,
     boolean cellHasFocus) {
   JLabel label =
       (JLabel)
           defaultRenderer.getListCellRendererComponent(
               list, record, index, isSelected, cellHasFocus);
   String formattedText = getFormattedText(record);
   label.setText(formattedText);
   if (!isSelected) {
     if (record.getFormattedMessage().startsWith("---")
         && record.getFormattedMessage().endsWith("---")) {
       label.setForeground(Color.GRAY);
     } else if (record.getLogLevel() == LogLevel.ERROR) {
       label.setForeground(new Color(220, 0, 0));
     } else if (record.getLogLevel() == LogLevel.WARN) {
       label.setForeground(new Color(255, 135, 0));
     } else if (record.getLogLevel() == LogLevel.DEBUG) {
       label.setForeground(Color.LIGHT_GRAY);
     }
   }
   label.setBorder(border);
   return label;
 }
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      setText(getFileChooser().getName((File) value));
      return this;
    }
示例#4
0
    @Override
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

      // ### We should indicate the current thread independently of the
      // ### selection, e.g., with an icon, because the user may change
      // ### the selection graphically without affecting the current
      // ### thread.

      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      if (value == null) {
        this.setText("<unavailable>");
      } else {
        StackFrame frame = (StackFrame) value;
        Location loc = frame.location();
        Method meth = loc.method();
        String methName = meth.declaringType().name() + '.' + meth.name();
        String position = "";
        if (meth.isNative()) {
          position = " (native method)";
        } else if (loc.lineNumber() != -1) {
          position = ":" + loc.lineNumber();
        } else {
          long pc = loc.codeIndex();
          if (pc != -1) {
            position = ", pc = " + pc;
          }
        }
        // Indices are presented to the user starting from 1, not 0.
        this.setText("[" + (index + 1) + "] " + methName + position);
      }
      return this;
    }
    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;
    }
 @Override
 public Component getListCellRendererComponent(
     JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
   String extension = FilenameUtils.getExtension(value.toString());
   if (extension != null) {
     setIcon(IconManager.instance().getIconForExtension(extension));
   }
   return this;
 }
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

      if (value != null && value instanceof FileFilter) {
        setText(((FileFilter) value).getDescription());
      }

      return this;
    }
示例#8
0
    @Override
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

      MediaDevice mediaDevice = (MediaDevice) value;

      Dimension screenSize = null;
      if (mediaDevice != null) screenSize = ((VideoMediaFormat) mediaDevice.getFormat()).getSize();

      this.setText(screenSize.width + "x" + screenSize.height);

      return this;
    }
示例#9
0
    /**
     * Sets readable text describing the resolution if the selected value is null we return the
     * string "Auto".
     *
     * @param list
     * @param value
     * @param index
     * @param isSelected
     * @param cellHasFocus
     * @return Component
     */
    @Override
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      // call super to set backgrounds and fonts
      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

      // now just change the text
      if (value == null) setText("Auto");
      else if (value instanceof Dimension) {
        Dimension d = (Dimension) value;

        setText(((int) d.getWidth()) + "x" + ((int) d.getHeight()));
      }
      return this;
    }
示例#10
0
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   super.getListCellRendererComponent(
       list, getPresentableString(value), index, isSelected, cellHasFocus);
   if (isSelected) {
     setForeground(UIUtil.getListSelectionForeground());
   } else {
     if (value instanceof VirtualFile) {
       VirtualFile file = (VirtualFile) value;
       if (!file.isValid()) {
         setForeground(INVALID_COLOR);
       }
     }
   }
   setIcon(getIconForRoot(value));
   return this;
 }
示例#11
0
    @Override
    public Component getListCellRendererComponent(
        JList<? extends Color> list,
        Color value,
        int index,
        boolean isSelected,
        boolean cellHasFocus) {
      JLabel renderer =
          (JLabel)
              defaultRenderer_.getListCellRendererComponent(
                  list, value, index, isSelected, cellHasFocus);
      renderer.setBackground(value);
      renderer.setText("");
      renderer.setPreferredSize(preferredSize_);

      return renderer;
    }
示例#12
0
    @Override
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

      ParentDirectoryRenderer.this.setBorder(new EmptyBorder(1, index * 5 + 1, 1, 1));

      if (value instanceof LoadingPlaceholder) {
        ParentDirectoryRenderer.this.setFont(plainFont);

        setIcon(showIcons ? FileCellRenderer.loadingIcon : null);
        setText(jEdit.getProperty("vfs.browser.tree.loading"));
      } else if (value instanceof VFSFile) {
        VFSFile dirEntry = (VFSFile) value;
        ParentDirectoryRenderer.this.setFont(boldFont);

        setIcon(showIcons ? FileCellRenderer.getIconForFile(dirEntry, true) : null);
        setText(dirEntry.getName());
      } else if (value == null) setText("VFS does not follow VFS API");

      return this;
    }
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
   setOpaque(isSelected);
   return this;
 }