Example #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;
    }
    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;
    }
Example #3
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;
    }
 /**
  * Paint a background for all groups and a round blue border and background when a cell is
  * selected.
  *
  * @param g the <tt>Graphics</tt> object
  */
 public void paintComponent(Graphics g) {
   Graphics g2 = g.create();
   try {
     internalPaintComponent(g2);
   } finally {
     g2.dispose();
   }
   super.paintComponent(g);
 }
    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;
    }
Example #6
0
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
   if (String.valueOf(value).equals("Original")) {
     setText(AppPrefs.getInstance().getMessages().getString("lblViewNameOriginal"));
   }
   // TODO, also remember about adding views, shouldn't allow localized original value
   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;
    }
Example #8
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;
    }
Example #9
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;
    }