• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jtable and vectors

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Silva.
 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic