How do I add a JLabel[] to a JTable?
问题 I have an array of JLabels which I want to add to a JTable. I tried using myJTable.add(myJLabelArray); Hoping it would work, but it doesn't (Obviously, otherwise I wouldn't be here). Can somebody please help? 回答1: Using add method is not the way to add components to a JTable . Components should never be added directly to a JTable or its TableModel . JLabels are just Swing components that render text. You can use a TableCellRenderer . Have a look at Editors & Renderers 回答2: You cannot just add