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 / Databases / April 2006

Tip: Looking for answers? Try searching our database.

How to set number of collumns and rows in JTable after JTable object was created?

Thread view: 
wierus - 28 Apr 2006 18:47 GMT
Hi, i have problem with JTable. I have to reuse JTable object after it
was previously created.  I don't know how many rows it must contains at
the moment of creation, so I could not use default constructor
JTable(int col,int row). Is it possible to dynamically set size of the
jtable?
I need this jtable to present data from database querry. It each time
user clicks button "Show records" querry to database is made and
regarding how many rows it returns JTable object should be set to
proper number of rows.
Bjorn Abelli - 29 Apr 2006 00:44 GMT
"wierus" wrote...

> Hi, i have problem with JTable. I have to reuse JTable object after it
> was previously created.  I don't know how many rows it must contains at
[quoted text clipped - 5 lines]
> regarding how many rows it returns JTable object should be set to
> proper number of rows.

This hasn't so much with databases to do, but more with GUI's...

Anyway, it's actually not the JTable itself that controls how many rows or
columns it contains, but the TableModel it has assigned to it.

http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/table/TableModel.html

There's two main ways of dealing with changes in the numbers of rows and
colums i JTables.

- assign a new TableModel to the JTable
- manipulate the existing TableModel

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#data

// Bjorn A


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.