我创建了一个与另一个类一起使用的 jTable 类。这里的代码:
public class Data_Table extends JFrame{
DefaultTableModel dtm;
JTable table;
JScrollPane scrollPane;
JFrame ventana;
JButton button1,button2;
JPanel pCentral,pSouth,pWindow;
public void init() {
String[] columnNames = {"CBD","abstract","final","native","private","protected","public",
"static","strictfp","synchronized","transient","volatile"};
dtm = new DefaultTableModel(columnNames,0);
table = new JTable(dtm);
scrollPane = new JScrollPane(table);
button1 = new JButton("Ok");
button2 = new JButton("Cancel");
}
public void addData(Object[] data) {
dtm.addRow(data);
}
public void createWindow() {
pCentral=new JPanel();
pCentral.add(scrollPane);
pSouth=new JPanel();
pSouth.add(button1);
pSouth.add(button2);
pWindow=new JPanel(new BorderLayout());
pWindow.add(pCentral,BorderLayout.CENTER);
pWindow.add(pSouth,BorderLayout.SOUTH);
ventana=new JFrame("");
ventana.setContentPane(pWindow);
ventana.add(scrollPane);
ventana.setSize(1000,200);
ventana.setLocationRelativeTo(null);
ventana.setVisible(true);
}
}
我想将列从abstract
tovolatile
转换为 jCheckBox。现在的结果是这样的:
我怎样才能改变我的桌子???