Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #36656 > unrolled thread

how to update JTable display

Started byEric Douglas <e.d.programmer@gmail.com>
First post2017-05-26 11:32 -0700
Last post2017-05-26 12:31 -0700
Articles 5 — 3 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  how to update JTable display Eric Douglas <e.d.programmer@gmail.com> - 2017-05-26 11:32 -0700
    Re: how to update JTable display Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-05-26 14:37 -0400
      Re: how to update JTable display Eric Douglas <e.d.programmer@gmail.com> - 2017-05-26 12:04 -0700
    Re: how to update JTable display Joerg Meier <joergmmeier@arcor.de> - 2017-05-26 21:17 +0200
      Re: how to update JTable display Eric Douglas <e.d.programmer@gmail.com> - 2017-05-26 12:31 -0700

#36656 — how to update JTable display

FromEric Douglas <e.d.programmer@gmail.com>
Date2017-05-26 11:32 -0700
Subjecthow to update JTable display
Message-ID<bbd6d1cf-5712-4156-8093-ddd41fe9cbfb@googlegroups.com>
Now I must be missing something stupid.  I make some changes to my table model, then I update the index array for my RowFilter from the TableModelListener, then I tell the table to repaint and the scrollpane to repaint and it's showing all wrong rows, but if I scroll it up and back it shows correctly.

[toc] | [next] | [standalone]


#36657

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2017-05-26 14:37 -0400
Message-ID<og9sfj$lg5$1@dont-email.me>
In reply to#36656
On 5/26/2017 2:32 PM, Eric Douglas wrote:
> Now I must be missing something stupid.  I make some changes to my table model, then I update the index array for my RowFilter from the TableModelListener, then I tell the table to repaint and the scrollpane to repaint and it's showing all wrong rows, but if I scroll it up and back it shows correctly.

     <http://www.sscce.org/>

     (In light of all the hoops you report jumping through, the first
"S" may be a non-trivial exercise.  Sorry about that -- but I can't
debug what I can't see.)

-- 
esosman@comcast-dot-net.invalid
Thirteen hundred thirty-five days to go.

[toc] | [prev] | [next] | [standalone]


#36658

FromEric Douglas <e.d.programmer@gmail.com>
Date2017-05-26 12:04 -0700
Message-ID<a75f515a-db63-4688-a12e-50b44ebd9aea@googlegroups.com>
In reply to#36657
On Friday, May 26, 2017 at 2:38:02 PM UTC-4, Eric Sosman wrote:
>      (In light of all the hoops you report jumping through, the first
> "S" may be a non-trivial exercise.  Sorry about that -- but I can't
> debug what I can't see.)
> 

Right, just wondering if there's a simple stupid obvious thing I'm missing to tell a table to update the display properly.  Creating the sscce won't be so easy.

I'm using a search with a RowFilter to process table cell values from lucene and display only ones that match.  I made a simple ArrayList of what to display, index = view row, value = model row.

public boolean include(final Entry<? extends Object, ? extends Object> entry) {
   final int idx = (int) entry.getIdentifier();
   if (convertRowIndexToModel(idx) >= 0) {
      return true;
   }
   return false;
}

public int convertRowIndexToModel(final int viewRowIndex) {
   return (rowToModelIndex.size() > viewRowIndex) ? rowToModelIndex.get(viewRowIndex) : -1;
}

This part is working perfectly.  Now I click a button which inserts a row in the middle while some rows are filtered out.  This fires a tableChanged event.  My TableModelListener tells it to reindex and update for the search.  Oddly the values update perfectly but the display doesn't.  Say I have 20 rows matching my filter and 10 visible, it's scrollable.  I can scroll up and back and the rows display correctly.  I could send all the code and it's dependencies to test but a simple executable sample to reproduce would take more time than I have right now.

[toc] | [prev] | [next] | [standalone]


#36659

FromJoerg Meier <joergmmeier@arcor.de>
Date2017-05-26 21:17 +0200
Message-ID<1lqv55iupd8e9.y7o8k9n1nhkp$.dlg@40tude.net>
In reply to#36656
On Fri, 26 May 2017 11:32:28 -0700 (PDT), Eric Douglas wrote:

> Now I must be missing something stupid.  I make some changes to
> my table model, then I update the index array for my RowFilter from
> the TableModelListener, then I tell the table to repaint and the
> scrollpane to repaint and it's showing all wrong rows, but if I
> scroll it up and back it shows correctly.

Did you remember to call

<http://docs.oracle.com/javase/8/docs/api/javax/swing/table/AbstractTableModel.html#fireTableDataChanged()>

?

Liebe Gruesse,
		Joerg

-- 
"Immer wieder erstaunlich, wie lächerlich man sich doch machen kann und
sich dabei noch toll finden." 
                        - Hartmut Kraus, 19.3.2017 in de.soc.recht.misc

Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [next] | [standalone]


#36660

FromEric Douglas <e.d.programmer@gmail.com>
Date2017-05-26 12:31 -0700
Message-ID<0bacbc2b-4565-43f7-bd7b-78086361b15e@googlegroups.com>
In reply to#36659
On Friday, May 26, 2017 at 3:17:27 PM UTC-4, Joerg Meier wrote:
> On Fri, 26 May 2017 11:32:28 -0700 (PDT), Eric Douglas wrote:
> 
> > Now I must be missing something stupid.  I make some changes to
> > my table model, then I update the index array for my RowFilter from
> > the TableModelListener, then I tell the table to repaint and the
> > scrollpane to repaint and it's showing all wrong rows, but if I
> > scroll it up and back it shows correctly.
> 
> Did you remember to call
> 
> <http://docs.oracle.com/javase/8/docs/api/javax/swing/table/AbstractTableModel.html#fireTableDataChanged()>
> 
> ?
> 
> Liebe Gruesse,
> 		Joerg
> 
> -- 
> "Immer wieder erstaunlich, wie lächerlich man sich doch machen kann und
> sich dabei noch toll finden." 
>                         - Hartmut Kraus, 19.3.2017 in de.soc.recht.misc
> 
> Ich lese meine Emails nicht, replies to Email bleiben also leider
> ungelesen.

I did, but I just tested firing it a second time... I think this might be working.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web