Hi there,
I'm trying to get to grips with Java ME development for the Pocket PC. I'm running the NSIcom CrE-ME emulator and building my application with NetBeans 6.5.
The application is based around three tab panels, each of which have Swing components. The contents Swing components are updated at various points in the application. These components include a JTextArea, JTextFields, and most significantly, a JTable within a JScrollPane.
The JTable is causing problems. If I initialise it through Matisse with some sample data, it appears. But if I try to set the reference of the JTable at runtime in the populateFields() method below, nothing appears. Note that this is simply with the sample table data from the Sun tutorial, not even my custom TableModel.
What am I doing wrong? Is there some obvious updating emthod I need to call, or some other glaring error/conecpt I've missed? I've tried practically every possible method I've come across that I thought might have something to do with it.
The populateFields() method is called at various times during the program.
public void populateFields()
{
String[] columnNames = {"First Name", "Last Name","Sport", "# of Years", "Vegetarian"};
Object[][] data = { {"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)},
{"Alison", "Huml", "Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false)},
{"Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true)},
{"Philip", "Milne", "Pool", new Integer(10), new Boolean(false)} };
this.tableSurvey = new JTable(new DefaultTableModel(data, columnNames));
this.scrollPaneSurvey = new JScrollPane(this.tableSurvey);
DefaultTableModel dtm = (DefaultTableModel) this.tableSurvey.getModel();
dtm.fireTableStructureChanged();
dtm.fireTableDataChanged();
this.scrollPaneSurvey.invalidate();
this.scrollPaneSurvey.validate();
this.panelSurvey.validate();
this.panelSurvey.repaint();
}