A
A
Andrey Lubchuk2016-01-17 17:57:02
Java
Andrey Lubchuk, 2016-01-17 17:57:02

JCheckBox in JTable Not clickable?

I added a JCheckBox to the table but nothing happens when I click on it. cc66aeaf8f4d4882b6bb9651905ee818.png
Its implementation

Random rnd = new Random();
                    for (int i = 0; i < n; i++) {
                        beans.add(new MyBean(nameb, priceb, quantityb, rnd.nextBoolean()));
                    }

public Class<?> getColumnClass(int column) {
            switch (column) {
                case 0:
                    return String.class;
                case 1:
                    return Float.class;
                case 2:
                    return Integer.class;
                case 3:
                    return Boolean.class;
            }
            return Boolean.class;
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kornachev, 2016-01-17
@AngelX96

Link to documentation
At the moment, the table works only for displaying the component (CellRenderer), you also need to edit (CellEditor). Open the documentation on the link above, skip the renderers and scroll down to the editors, you will understand everything on the ComboBox and ColorChooser primer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question