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 / GUI / April 2007

Tip: Looking for answers? Try searching our database.

How to create expanding Tables (Web 2.0 Style) with Swing ?

Thread view: 
jfelde@googlemail.com - 23 Apr 2007 11:00 GMT
Hi There,

As I am working on a GUI for a little Aplication of mine, I am
wondering how to create expanding Table Rows with Swing. I whish to
have Table Rows that can, for Example by clicking or hovering the
Mousecursor over them, expand and show additional Info to the
coresponding Row.
I could do this with Tolltips, but I would prefere to have the Row
expand and stay that way until some other action occurs. The Pictur i
have in Mind about it is simmilar to the Tables that work with hidden
layers senn on so many Websites on the Internet.

Any Suggestions and IDeas are welcome,

thanks for your efforts,

Sungu
Andrew Thompson - 23 Apr 2007 11:36 GMT
...
>...I whish to
>have Table Rows that can, for Example by clicking or hovering the
>Mousecursor over them, expand and show additional Info to the
>coresponding Row.
>I could do this with Tolltips, but I would prefere to have the Row
>expand and stay that way until some other action occurs.
...
>Any Suggestions and IDeas are welcome,

I do not know the answer to your immediate question,
but wanted to add that JTable has a reputation of being
horrendously difficult to change or tweak.  My suggestion
is that you settle for tool tips, or some other strategy that
might (for example) show the extra rows in a second JTable
in another part of the GUI.

(BTW - your use of upper case letters is quite unusual,
I would normally expect to see upper case for ..
- The start of a sentence.
- Mention of class names like JTable.
- Proper nouns, like the word 'I'.)

Signature

Andrew Thompson
http://www.athompson.info/andrew/

jfelde@googlemail.com - 23 Apr 2007 12:38 GMT
First of all, thanks for the answer :)

By my research on the Web i have discovered a lot of different
statements regarding the problems and difficulties concerning the use
of JTable.
None of them however matched my idea of expanding table rows cloesly
enough to hve ma back up from the idea, so i sought of Googlegroups as
one of the plaxes where i might maybe find someone who may have tried
it or have experience with the problem...

As for my use of upper case letters, i must appologize, i hwas in a
hurry nd currently run through an german spelling training (they have
some really weird conventions for when to use capital letters) so i
got a bit confused, sorry about the mess ;)

Anyway, should anyone have a goot Idea on how to build expandable
table rows with JTable just let me know ;)

thangs for your efforts,

Sungu
Josh Falter - 24 Apr 2007 14:48 GMT
I have never attempted this, so I don't know if it would work, but
here is what I would try....
Start with a JTable that you have created a custom TableModel for (so
that you can control the data organization).  Add a
MouseMotionListener to the JTable.  When a MouseEvent event is
received, create a Point Object from the coordinates of the event
(using MouseEvent.getPoint) and use the JTable functions
columnAtPoint() and rowAtPoint() to determine if having the mouse over
this location in the JTable should cause the data to change.  If new
data should then be shown, I would call some custom function in the
TableModel that would insert a new row and set some flags that would
be used in the getValueAt() function to inject the new data into the
next row and move all the other data down a row.  Then call
fireTableDataChanged() to get the GUI to update the data displayed.
You would also then have to listen for when the Mouse has moved to a
new location so that you can delete that extra row and reset the data,
which would probably involve the MouseMotionListener as well as a
MouseListener to determine if the mouse has left the component all
together.

HTH - Josh
jfelde@googlemail.com - 26 Apr 2007 12:33 GMT
Josh, thanks a lot for the suggestion.
This hels a lot an I am going to try it this way as soon as I find
some time for it.
When I have created something usefull, or if problems arise that i can
not cope with myself, ill post here again.

Should I succeed I'll post the sourcecode here as well. It's gona take
some days (having university final tests until May 5th ) but I'll kepp
this updated.

tahnks again for your efforts and your help,

Sungu
jfelde@googlemail.com - 23 Apr 2007 12:52 GMT
First of all, thanks for the answer :)

By my research on the Web i have discovered a lot of different
statements regarding the problems and difficulties concerning the use
of JTable.
None of them however matched my idea of expanding table rows cloesly
enough to hve ma back up from the idea, so i sought of Googlegroups as
one of the plaxes where i might maybe find someone who may have tried
it or have experience with the problem...

As for my use of upper case letters, i must appologize, i hwas in a
hurry nd currently run through an german spelling training (they have
some really weird conventions for when to use capital letters) so i
got a bit confused, sorry about the mess ;)

Anyway, should anyone have a goot Idea on how to build expandable
table rows with JTable just let me know ;)

thangs for your efforts,

Sungu
RC - 30 Apr 2007 20:37 GMT
Put the JComboBox or JTree inside the JTable.


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



©2008 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.