This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jtable and vectors

 
David Shepherd
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi,
try out this...
getContentPane().add(table.getTableHeader(),BorderLayout.NORTH);
getContentPane().add(table);
silva.
 
David Shepherd
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Silva.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic