/**
  * Creates the default renderer that will be used in a non-editiable combo box. A default renderer
  * will used only if a renderer has not been explicitly set with <code>setRenderer</code>.
  *
  * <p>This method differs from the superclass implementation in that it uses an empty border with
  * wider left and right margins of 2 pixels instead of 1.
  *
  * @return a <code>ListCellRender</code> used for the combo box
  * @see javax.swing.JComboBox#setRenderer
  */
 protected ListCellRenderer createRenderer() {
   if (tableCellEditor) {
     return super.createRenderer();
   }
   BasicComboBoxRenderer renderer = new BasicComboBoxRenderer.UIResource();
   renderer.setBorder(UIManager.getBorder("ComboBox.rendererBorder"));
   return renderer;
 }
  @Override
  public Component getListCellRendererComponent(
      JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    String s = getText();
    setOpaque(cellHasFocus || isSelected);
    setToolTipText(s);
    if (s.length() > 60) {
      s = s.substring(0, 60) + "...";
      setText(s);
    }

    return this;
  }
Exemple #3
0
 public void paintComponent(Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   super.paintComponent(g);
 }