Hi,
I am new to the JTable component... I have set up a JTabel which displays some sample information. I have to display results I get from one of my methods... There is the Swing/JTable tutorial at http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#modelchange ("Detecting Data Changes"), however, the necessary code has been removed from the tutorial! I hope you can help me...
I have set up the following table:
public class InfoDialog extends JDialog {
String[] columnNames = {"Type", "Value"};
Object[][] data = {
{"Angle", "90"},
{"Speed", "50"},
};
public InfoDialog() {
Container cp = this.getContentPane();
setLayout(new BoxLayout(cp, BoxLayout.PAGE_AXIS));
JTable table = new JTable(data, columnNames);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JPanel tablePanel = new JPanel();
tablePanel.setLayout(new BorderLayout());
tablePanel.add(table.getTableHeader(), BorderLayout.PAGE_START);
tablePanel.add(table, BorderLayout.CENTER);
(...)
From one of my other classes, GameStart, one of the methods, calculateAngle, returns the measured angle. I would like to display this result in the appropriate cell.
In the Swing tutorial I just can read "You can see the code for that method in [PENDING: The Bingo example has been removed.]"
So I am a little bit confused. I think I have to first extend AbstractTableModel, then I have something to do with fireTableCellUpdated... Can you maybe show me a working example or is this "Bingo example" from the Swing available elsewhere?
Thanks for your help!