wood burning stoves 2.0*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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.
 
 
subject: Jtable and vectors