This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Jtable and vectors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Jtable and vectors" Watch "Jtable and vectors" New topic
Author

Jtable and vectors

David Shepherd
Ranch Hand

Joined: Mar 02, 2001
Posts: 35
I am trying to use a JTable with the default table model. I am passing in a vector of vectors and a vector of Strings (for the labels). I can't get the labels to show up put I do see a little tiny box where the column headings should go (I assume). I am adding table to a scrollPane and then to a panel. I can see the data values but can't get the column names to appear
Vector vColumnNames = new Vector();
vColumnNames.add("Style");
Vector vData = new Vector();
Vector vStuff= new Vector();
vStuff.add("vector");
vData.add(vStuff);
System.out.println("the vector value " + vColumnNames.firstElement().toString());
DefaultTableModel x = new DefaultTableModel(vData,vColumnNames);
JTable tblMap = new JTable(x);
selvas kumars
Ranch Hand

Joined: Jan 06, 2001
Posts: 115

hi,
try out this...
getContentPane().add(table.getTableHeader(),BorderLayout.NORTH);
getContentPane().add(table);
silva.
David Shepherd
Ranch Hand

Joined: Mar 02, 2001
Posts: 35
Thank you Silva.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jtable and vectors
 
Similar Threads
JTable ClassCastException...
jtable not refreshing
JTable
JTable
JTable