JColorChooser in a JTable

1.1k views Asked by At

enter image description here

I have a very simple class displaying a jTable, where in column1 I have added a combobox

public class Table extends javax.swing.JFrame {

   public Table() {
    initComponents();
    TableColumn name = jTableProva.getColumnModel().getColumn(1);

    JComboBox combo = new JComboBox();
    combo.addItem("Rain");
    combo.addItem("Snow");
    combo.addItem("Sunny");

    name.setCellEditor(new DefaultCellEditor(combo));
}

My questions:

1) I don't know why combos always appears hidden or "behind" cells when run.

2) I would like to add a JColorChooser in column 2. How can I accomplish this using the Netbeans swing component code? I have added a JColorChooser by drag and drop from palette.

Thanks.

1

There are 1 answers

0
trashgod On

Absent your sscce, it's not clear what the problem might be. You can compare what you're doing with this working example that shows a DefaultCellEditor having a JComboBox. Using a Combo Box as an Editor also shows a JComboBox; Using Other Editors shows a JButton that launches a JColorChooser.