Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with JTable  RSS feed

 
Sergio Zuniga
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple table model and the problem i have is that my table doesen't show the columns names(i have a String[] with te columns, and they are ok).. i don't know what happened..
The table shows OK, but the columnNames are not OK.
any ideas ??
thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for the column names to appear, the table has to be added to a scrollpane.
 
Sergio Zuniga
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have something like this..



thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
depending on where you want the table added, one of these lines is wrong
add(scrollPane);
JPanel1.add(table);

either
add(scrollPane); or
JPanel1.add(scrollpane);

but not both

it could even be this
JPanel1.add(scrollpane);
add(JPanel1);

here's a simple example program

 
Sergio Zuniga
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much !! that worked just fine..
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!