Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

A JTable with column headers but no rows  RSS feed

 
Barry Brashear
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.
 
Pat Peg
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);
 
Mike Rainville
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see

setVisible(true);

at the bottom...
 
Michael Dunn
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

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!