• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

A JTable with column headers but no rows

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone tell me how to instantiate a JTable that has column headers
but does not have any rows?

Thanks.
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I do not understand you question but just don't put any Data in the table...
 
Barry Brashear
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that. I'm not seeing anything in the table.

private Vector mColumnNames ;
private Vector mColumns;

mColumnNames = new Vector();
mColumns = new Vector();

mColumnNames.addElement("Last");
mColumnNames.addElement("First");
mColumnNames.addElement("Brd Status");
mColumnNames.addElement("Customer Type");
mColumnNames.addElement("PB/Pax Type");
mColumnNames.addElement("ID");
mColumnNames.addElement("Special Conditions");
mColumnNames.addElement("Baggage");
mColumnNames.addElement("Add Remarks");

JTable table = new JTable(mColumns, mColumnNames);
JScrollPane scrollPane = new JScrollPane( table,
JScrollPane. VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );

getContentPane().add( scrollPane , BorderLayout.CENTER);
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see

setVisible(true);

at the bottom...
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this works OK, setting a size, but (continued at bottom)



but perhaps you mean you want to see rows, without data. If so, try this

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!