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;
    }
    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;
    }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 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;
    }
Ejemplo n.º 5
0
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean selected, boolean hasFocus) {
   // Never paint cells as "selected."
   super.getListCellRendererComponent(list, value, index, false, hasFocus);
   setBorder(CELL_BORDER);
   //			setBackground(table.getBackground());
   return this;
 }
Ejemplo n.º 6
0
 /**
  * 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);
 }
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
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;
    }
 @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;
 }
        @Override
        public Component getListCellRendererComponent(
            JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
          if (AntialiasingType.SUBPIXEL.equals(value)) {
            ourDefaultListCellRenderer.putClientProperty(
                SwingUtilities2.AA_TEXT_PROPERTY_KEY,
                new SwingUtilities2.AATextInfo(RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB, 140));
          } else if (AntialiasingType.GREYSCALE.equals(value)) {
            ourDefaultListCellRenderer.putClientProperty(
                SwingUtilities2.AA_TEXT_PROPERTY_KEY,
                new SwingUtilities2.AATextInfo(RenderingHints.VALUE_TEXT_ANTIALIAS_ON, 140));
          } else if (AntialiasingType.OFF.equals(value)) {
            ourDefaultListCellRenderer.putClientProperty(
                SwingUtilities2.AA_TEXT_PROPERTY_KEY, null);
          }

          ourDefaultListCellRenderer.setText(value.toString());

          return ourDefaultListCellRenderer;
        }
    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;
    }
  @Override
  public Component getListCellRendererComponent(
      JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    DefaultListCellRenderer c =
        (DefaultListCellRenderer)
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    MassResult r = (MassResult) value;

    int similarity = r.getSimilarity();

    String text = Integer.toString(similarity);

    c.setText(text);

    BufferedImage thumb = r.getThumbnail();

    c.setIcon(new ImageIcon(thumb));

    c.setBorder(border);

    c.setOpaque(isSelected);

    c.setToolTipText((r.isMalignant() ? "Malignant" : "Benign") + ", Similarity: " + text);

    return c;
  }
Ejemplo n.º 13
0
    public Component getListCellRendererComponent(
        final JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

      try {
        setForeground(foreC.get(index - 1));
        setBackground(backC.get(index - 1));
      } catch (Exception ex) {
        // ignore exception
      }
      setText(value.toString());

      return this;
    }
Ejemplo n.º 14
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;
    }
Ejemplo n.º 15
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;
    }
Ejemplo n.º 16
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;
 }
Ejemplo n.º 17
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;
    }
Ejemplo n.º 18
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;
    }
Ejemplo n.º 19
0
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      if (value instanceof SeparatorIcon) {
        setComponentOrientation(list.getComponentOrientation());
        setFont(list.getFont());
        setText("");
        setBorder(null);
        setIcon((Icon) value);
        setBackground(list.getBackground());
        setForeground(list.getForeground());
        setHorizontalAlignment(SwingConstants.LEFT);
        return this;
      }

      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      if (value instanceof Icon) setHorizontalAlignment(SwingConstants.CENTER);
      else if (value instanceof Integer) setHorizontalAlignment(SwingConstants.RIGHT);
      else
        // String or other text component (value.toString())
        setHorizontalAlignment(SwingConstants.LEFT);
      return this;
    }
Ejemplo n.º 20
0
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
   setOpaque(isSelected);
   return this;
 }
Ejemplo n.º 21
0
  public OptionsDialogOld(JFrame parent) {

    super(parent, true);

    game = new SurroundGame(10, 2, 1, 1);

    setTitle("Game Options");
    setUndecorated(true);
    closeStatus = false;

    try {
      background =
          ImageIO.read(
              new File(
                  "C:\\Users\\Frank\\" + "workspace\\Surround\\src\\package1\\" + "bcktile.png"));
    } catch (IOException e) {
      JOptionPane.showMessageDialog(null, "Image not found");
    }

    Font font2 = new Font("Cooper Black", Font.BOLD, 30);

    okButton = new JButton("OK");
    okButton.setFont(font2);
    cancelButton = new JButton("CANCEL");
    cancelButton.setFont(font2);
    okButton.addActionListener(this);
    cancelButton.addActionListener(this);

    JPanel container = new ImagePanel(background);
    container.setLayout(new BorderLayout());
    JLabel title = new JLabel("Game Options", SwingConstants.CENTER);
    Font font = new Font("Cooper Black", Font.BOLD, 60);
    title.setFont(font);
    // title.setAlignmentX(CENTER_ALIGNMENT);
    container.add(BorderLayout.NORTH, title);

    JPanel panel = new JPanel();
    panel.setName("Game Options");
    panel.setLayout(new GridLayout(5, 2));
    DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
    dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
    String[] board = {
      "4 x 4", "5 x 5", "6 x 6", "7 x 7", "8 x 8", "9 x 9", "10 x 10", "11 x 11", "12 x 12"
    };
    boardBox = new JComboBox<String>(board);
    boardBox.setFont(font2);
    boardBox.setRenderer(dlcr);

    JLabel sizeLabel = new JLabel("Size of the board:");
    sizeLabel.setFont(font2);
    panel.add(sizeLabel);
    panel.add(boardBox);
    String[] players = {"2", "3", "4", "5", "6", "7", "8", "9", "10"};
    String[] turns = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
    playersBox = new JComboBox<String>(players);
    playersBox.setFont(font2);
    playersBox.setRenderer(dlcr);
    JLabel playersLabel = new JLabel("Number of players:");
    playersLabel.setFont(font2);
    panel.add(playersLabel);
    panel.add(playersBox);
    humansBox = new JComboBox<String>(turns);
    humansBox.setFont(font2);
    humansBox.setRenderer(dlcr);
    JLabel humansLabel = new JLabel("Number of human players:");
    humansLabel.setFont(font2);
    panel.add(humansLabel);
    panel.add(humansBox);
    startBox = new JComboBox<String>(turns);
    startBox.setFont(font2);
    startBox.setRenderer(dlcr);
    JLabel startLabel = new JLabel("Starting player:");
    startLabel.setFont(font2);
    panel.add(startLabel);
    panel.add(startBox);

    panel.add(okButton);
    panel.add(cancelButton);

    // container.setPreferredSize(new Dimension(700,700));
    container.add(BorderLayout.CENTER, panel);

    panel.setOpaque(false);
    container.setOpaque(false);

    Box box = new Box(BoxLayout.Y_AXIS);
    box.add(Box.createVerticalGlue());
    box.add(container);
    // box.setVisible(true);

    // setContentPane(background);
    // background.
    getContentPane().add(box);
    // add(box);
    // getContentPane().add(container);

    setAlwaysOnTop(true);

    setSize(parent.getSize());
    setLocation(parent.getLocation());

    setVisible(true);
  }