File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Adding to JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding to JTable" Watch "Adding to JTable" New topic

Adding to JTable

Al Wells
Ranch Hand

Joined: Apr 18, 2005
Posts: 87
How do I add a vector to JTable and get it to display. What I
have tried is not working. I am also interested in other
methods I can use to accomplish the same thing but that may also be
more visually pleasing to the user.

I tried building the vector and then just adding it to the table.
That did not work. The code follows and I thank you for your assistance.

[ June 02, 2005: Message edited by: Al Wells ]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
from the api docs, this would be the relevant constructor


public JTable(Vector rowData,
Vector columnNames)

Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames. The Vectors contained in rowData should contain the values for that row. In other words, the value of the cell at row 1, column 5 can be obtained with the following code:


rowData - the data for the new table
columnNames - names of each column
[ June 02, 2005: Message edited by: Michael Dunn ]
I agree. Here's the link:
subject: Adding to JTable
It's not a secret anymore!