swingx
  1. swingx
  2. SWINGX-1244

NPE on fireDataChanged when model is void

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Incomplete
    • Affects Version/s: 1.6
    • Fix Version/s: 1.6.1
    • Component/s: Table
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      1,244

      Description

      Hi,

      I get exception [1] on this code [2] when model is not null but contains 0 rows .

      Not sure but I don't see this as a regular behavior (I'm may be wrong on it). Of
      course, a workaround is to call the fireDataChanged() method only when nb row > 0:

      if (model.getRowCount() > 0) {
      model.fireTableDataChanged();
      }
      else{
      // force table repainting, called by fireTableDataChanged() when used
      jtable.revalidate();
      jtable.repaint();
      }

      In this case, the table is correctly refreshed (and is voided).

      [1] the NPE
      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at java.lang.Class.isAssignableFrom(Native Method)
      at
      org.jdesktop.swingx.sort.TableSortController.useToString(TableSortController.java:121)
      at javax.swing.DefaultRowSorter.updateUseToString(DefaultRowSorter.java:607)
      at javax.swing.DefaultRowSorter.sort(DefaultRowSorter.java:556)
      at javax.swing.DefaultRowSorter.allRowsChanged(DefaultRowSorter.java:835)
      at javax.swing.JTable.notifySorter(JTable.java:4224)
      at javax.swing.JTable.sortedTableChanged(JTable.java:4084)
      at javax.swing.JTable.tableChanged(JTable.java:4361)
      at org.jdesktop.swingx.JXTable.tableChanged(JXTable.java:1524)
      at
      javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:280)
      at
      javax.swing.table.AbstractTableModel.fireTableDataChanged(AbstractTableModel.java:182)
      at org.jajuk.ui.views.AbstractTableView$5.done(AbstractTableView.java:425)
      at javax.swing.SwingWorker$5.run(SwingWorker.java:718)
      at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:864)
      at sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:95)
      at
      javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(SwingWorker.java:874)
      at javax.swing.Timer.fireActionPerformed(Timer.java:271)
      at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
      at
      java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:284)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
      at
      java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

      [2] code:
      SwingWorker<Void, Void> sw = new SwingWorker<Void, Void>() {
      @Override
      public Void doInBackground()

      { model.removeTableModelListener(AbstractTableView.this); model.populateModel(sPropertyName, sPropertyValue, jtable.getColumnsConf()); model.addTableModelListener(AbstractTableView.this); return null; }

      @Override
      public void done()

      { model.fireTableDataChanged(); jtable.revalidate(); jtable.repaint(); }

      };
      sw.execute();

        Activity

        Hide
        bflorat added a comment -

        You can close this ticket, the problem was our own : we has an issue overriding
        getColumnClass method :

        @Override
        public Class<? extends Object> getColumnClass(int columnIndex) {
        Object o = getValueAt(0, columnIndex);
        if (o != null)

        { return o.getClass(); }

        else

        { return null; }

        }

        but we should return Object.class (or another class) if rownum = 0;

        Show
        bflorat added a comment - You can close this ticket, the problem was our own : we has an issue overriding getColumnClass method : @Override public Class<? extends Object> getColumnClass(int columnIndex) { Object o = getValueAt(0, columnIndex); if (o != null) { return o.getClass(); } else { return null; } } but we should return Object.class (or another class) if rownum = 0;
        Hide
        kleopatra added a comment -

        glad you found the reason for the problem

        Happy New Year
        Jeanette

        Show
        kleopatra added a comment - glad you found the reason for the problem Happy New Year Jeanette

          People

          • Assignee:
            kleopatra
            Reporter:
            bflorat
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: