J'essaie d'ajouter un groupe de boutons radio similaire à http://www.java2s.com/Code/Java/Swing-Components/RadioButtonTableExample2.htm dans mon formulaire, j'ai suivi le tutoriel ci-dessus mais j'utilise AbstractTableModel au lieu de DefaultTableModel. Voici mon code, il doesnot montrer quoi que ce soit sur colomun aucune erreur:ne montrant pas le groupe bouton radio à l'intérieur coloum dans jtable
StudentTableModel model = new StudentTableModel(studentList);
// JScrollPane scrollPane = new JScrollPane(table);
final JScrollPane scrollPane = new JScrollPane(
table,
JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
Dimension d = table.getPreferredSize();
scrollPane.setPreferredSize(
new Dimension(d.width,table.getRowHeight()*rows));
// code for radio buttons
String[] answer = { "A", "B", "C" };
TableColumnModel columnModel = table.getColumnModel();
for (int tc = 7; tc < table.getColumnCount(); tc++)
{
columnModel.getColumn(tc).setCellRenderer(
new MainClass().new RadioButtonRenderer(answer));
columnModel.getColumn(tc).setCellEditor(
new MainClass().new RadioButtonEditor(new JCheckBox(), new MainClass().new RadioButtonPanel(
answer)));
}
table.setModel(model);
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
frame.getContentPane().add(navigation, BorderLayout.SOUTH);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
Merci d'avance !!