• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting Number of Columns on JTable

 
Karen Baog
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

How do you set the number of columns on a JTable?
I also have a defaulttablemodel, and need this to be editable.

Cheers, everyone!
 
sasi kala
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

To set number of columns in the table add this method to DefaultTableModel class

public int getColumnCount()
{
int columnCount = // specify the number u want
return columnCount;
}

Hope This Helps
All The Best
[ April 21, 2005: Message edited by: sasi kala ]
 
David Dickinson
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karen,

To make cells editable you can use the following method (example provided)..

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