2 Replies Latest reply: Feb 7, 2010 2:47 PM by 843851 RSS

    SimpleTable adapter...how to use it?

    843851
      Hallo,

      this is my first attempt to use javame, even if i used javase and other programming languages first.

      I'm trying to make a simple app that elaborates some data, displays it in a table and then re-elaborate ad refreshes it.

      I managed to use the simpleTable table adapter in a midlet, but every try to update data simply does nothing.

      This is the actual getter (unmodified)
          public SimpleTableModel getTableModel1() {
              if (tableModel1 == null) {
                  // write pre-init user code here
                  tableModel1 = new SimpleTableModel(new java.lang.String[][] {
                      new java.lang.String[] { "1", "2", "3", "4", "5" }}, new java.lang.String[] { "Exe", "S", "R", "W", "P" });
                  // write post-init user code here
              }
              return tableModel1;
          }
      This is what i tried:

      The simpleTableModel is already attached to the table, so i tried to "reconstruct" it with my data upon refresh event.
      Same constructor, different data values, ending array is the column headers.

      The following code is executed hitting a commandItem. (i used System.out.println to ensure the code is executed)
      tableModel1 = new SimpleTableModel(new java.lang.String[][] {
                      new java.lang.String[] { "6", "7", "8", "9", "0" }}, new java.lang.String[] { "Exe", "S", "R", "W", "P" });
      
      tableModel1.fireTableModelChanged();
      No compile nor runtime errors, but no changes!

      What am i doing wrong?

      I already googled for answers, but unsuccesfully.

      If you can head me to the right documentation, it is ok too... i just need to implement the refreshing tables...

      Thanks very much!

      Luca