Не может удалить границы jcombobox

Я пытаюсь удалить границы нередактируемого комбинированного списка некоторое время, я провел некоторые исследования и смог удалить границы, установить заголовок и удалить значок стрелки, а также некоторые другие вещи. Но я не могу понять, почему в выпадающем списке все еще есть эти "линии" до и после выбранного элемента.

Как вы можете видеть на этом изображении ( http://d.pr/i/TdDS). Кто-то знает как это убрать?

showField= new JComboBox();
showField.setBounds(186,504,150,35);
showField.setRenderer(new ItemRenderer());
showField.setEditor(new ItemEditor());
showField.setModel(new DefaultComboBoxModel(new String{"How I Met Your Mother","Greys Anatomy","The Big Bang Theory","Leverage"}));
contentPane.add(serieField);

...

public class ItemEditor extends BasicComboBoxEditor {

private JPanel panel = new JPanel();
private JTextField item = new JTextField();
private String selectedValue;

public ItemEditor(){
    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    constraints.insets = new Insets(2,5,2,2);

    item.setOpaque(false);
    item.setHorizontalAlignment(JTextField.LEFT);
    item.setForeground(Color.WHITE);
    item.setFont(new Font("Calibri", 0, 11));
    item.setBorder(null);

    panel.add(item, constraints);
    panel.setBackground(new Color(44,44,44));
    panel.setBorder(null);
}

public Component getEditorComponent() {
    return this.panel;
}

public Object getItem() {
    return this.selectedValue;
}

public void setItem(Object obj) {
    if(obj == null)
        return;
    String showItem = (String) obj;
    selectedValue = showItem;
    item.setText(selectedValue);        
}
}

...

public class ItemRenderer extends JPanel implements ListCellRenderer {

private JTextField item = new JTextField();

public ItemRenderer() {
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    constraints.insets = new Insets(2,2,2,2);

    item.setOpaque(true);
    item.setHorizontalAlignment(JTextField.LEFT);
    item.setFont(new Font("Calibri", 0, 11));
    item.setBorder(null);

    add(item, constraints);
}

public void paint(Graphics g) {
    this.setBorder(null);
    super.paint(g);
}

public Component getListCellRendererComponent(JList list, Object value,
        int index, boolean isSelected, boolean cellHasFocus) {
    String showItem = (String) value;

    item.setText(showItem);
    item.setForeground(Color.WHITE);

    if (isSelected)
        item.setBackground(new Color(119, 119, 119));
    else
        item.setBackground(new Color(44, 44, 44));

    return this;
}
}

0 ответов

Другие вопросы по тегам