Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating jtable dynamically  RSS feed

 
Harnoor Singh
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am working on project where we have requirement that we need to create different jtables based on number of number of users. One table will be ceated for each user. So if there are 10 users, then we need to create 10 jtables. Kindly let me know if it is technically feasible. I tried to start solving problem by first creating number of jtables in for loop. However problem is that how will i select the jtable name at runtime. Other problem I am coming across is that how will jtable fit in the jframe. If any one has worked with this kind of problem please provide inputs. Thanks in advance.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just a thought...

add each table/scrollpane to a panel
add each panel to a CardLayout panel
add the CardLayout panel to a frame
add the userNames to a menu
link each menuItem to its respective user panel/table, via cardLayout.show(...)
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better suitable on the GUI forum. Moving...
 
Harnoor Singh
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael.

I want each table on the same jframe. Here is my approach to problem,, create jscrollpanes and jtables in for loop. Then add jtable to scrollpane. I am keeping all the jscrollpanes in one Map. Now how can i add these jscrollpanes to jframe.
 
Paul Clapham
Sheriff
Posts: 22503
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You add 10, or 500, JTables to the frame in just the same way you'd add one of them. Make sure you've chosen a layout manager which is suitable for that, though.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!