Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2010

Tip: Looking for answers? Try searching our database.

Design question: "threaded view" in table component

Thread view: 
Luc Van Bogaert - 04 Feb 2010 20:34 GMT
Hi,

For a personal hobby project, I'm writing a usenet client. One of the
"obstacles" I'm facing is the question of how to design the table
that displayes the articles headers, and more specifically how to
design a functionality that allows to display "threads" of related
articles, and at the same time maintain the various table columns,
like "subject", "author", etc.

At first I was thinking about using JTree, but that seems hard to
combine with the various table rows and columns. Now, I'm thinking of
just using table rows, and using a customized cell renderer depending
on the article "level" in the thread.

What do you think? Any suggestions are greatly appreciated.
Thanks,

Signature

Luc Van Bogaert.

Eric Sosman - 04 Feb 2010 21:58 GMT
> Hi,
>
[quoted text clipped - 9 lines]
> just using table rows, and using a customized cell renderer depending
> on the article "level" in the thread.

    One possibility would be a JTree, with the lowest-level
entries manually formatted.  You'd need to handle changes in
column width and arrangement yourself.

    It seems simpler, though, to use an ordinary JTable and to
show the thread relationship by indenting the entries in one
of the columns.  "Expanding" and "minimizing" threads would be
done by firing change notifications from the TableModel.

Signature

Eric Sosman
esosman@ieee-dot-org.invalid

Henk - 05 Feb 2010 16:25 GMT
> Hi,
>
[quoted text clipped - 15 lines]
> --
> Luc Van Bogaert.

What you seem to need is something called a "TreeTable". There are
several examples on the net, including:
http://java.sun.com/products/jfc/tsc/articles/treetable1/

Basically, the trick is to use a JTree as a TableCellRenderer,
combined with a hybrid TreeModel/TableMdel

Henk van Voorthuijsen
Jens Vonderheide - 07 Feb 2010 11:25 GMT
> What you seem to need is something called a "TreeTable". There are
> several examples on the net, including:
> http://java.sun.com/products/jfc/tsc/articles/treetable1/
>
> Basically, the trick is to use a JTree as a TableCellRenderer,
> combined with a hybrid TreeModel/TableMdel

While using this TreeTable, I ran into some problems (that was some time
ago, these are the comments I left in the code):

- First of all, use the updated code from the second article
(http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html)
- AbstractTreeTableModel#getColumnClass must be overridden to return
  TreeTableModel.class for column 0. Otherwise, the tree controls are
  not displayed at all.
- When the class is overridden, #getValueAt is not called anymore for
  column 0. Instead, #toString is called on the object. As a
  workaround, a special tree cell renderer must be installed on the
  tree internally used by JTreeTable, that in turn calls #getValueAt
  again.
  Note: This is the default behavior of JTrees, not a bug in
  JTreeTable.

Otherwise, the TreeTable is working very well. Of course, I had to add
seom @OverrideS and the like to keep modern compilers from complaining. :)

Jens
John B. Matthews - 07 Feb 2010 16:12 GMT
> > What you seem to need is something called a "TreeTable". There are
> > several examples on the net, including:
[quoted text clipped - 18 lines]
>    Note: This is the default behavior of JTrees, not a bug in
>    JTreeTable.

Thank you for this update. What did you use for FileSystemModel2.java?
The promised zip download is not extant, and I reported what appears to
be a missing file link.

For reference, there's a third article in the series, which seems to
have all it's files:

<http://java.sun.com/products/jfc/tsc/articles/bookmarks/>

Signature

John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

Jens Vonderheide - 07 Feb 2010 23:33 GMT
>> - First of all, use the updated code from the second article
>> (http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html)

> Thank you for this update. What did you use for FileSystemModel2.java?
> The promised zip download is not extant, and I reported what appears to
> be a missing file link.

I just downloaded the files manually and ignored FileSystemModel2.java,
since it's only an example and not required for the TreeTable.

> For reference, there's a third article in the series, which seems to
> have all it's files:
>
> <http://java.sun.com/products/jfc/tsc/articles/bookmarks/>

Thanks, I'll check out the new TreeTable. It's really a shame that such
a useful widget is hidden in some old articles.

Jens
John B. Matthews - 11 Feb 2010 13:35 GMT
[...]
> > Thank you for this update. What did you use for
> > FileSystemModel2.java? The promised zip download is not extant, and
[quoted text clipped - 3 lines]
> FileSystemModel2.java, since it's only an example and
> not required for the TreeTable.

Just curious. FWIW, Oracle/Sun acknowledged the report.

> > For reference, there's a third article in the series, which seems
> > to have all it's files:
[quoted text clipped - 3 lines]
> Thanks, I'll check out the new TreeTable. It's really a shame that
> such a useful widget is hidden in some old articles.

Agreed. It looks nice with the L&Fs I have available; now I have to
figure out why it breaks with Apple's L&F.

Signature

John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

Luc Van Bogaert - 08 Feb 2010 06:17 GMT
> What you seem to need is something called a "TreeTable". There are

> several examples on the net, including:

> http://java.sun.com/products/jfc/tsc/articles/treetable1/

Thanks, I'll look into this.

Signature

Luc Van Bogaert.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.