If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > how to setsize for columns of JTable

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-10, 12:30
panhavuth panhavuth is offline
Registered User
 
Join Date: Feb 2010
Posts: 4
Post how to setsize for columns of JTable

Please help me

In my JTable maybe have a lot of columns.

How can i set size of each column?
How can i have horizontal scroll bar if have too columns?


please help
Reply With Quote
  #2 (permalink)  
Old 02-27-10, 12:56
panhavuth panhavuth is offline
Registered User
 
Join Date: Feb 2010
Posts: 4
JTable table=new JTable();//your table should have JScollPan and already setsize in JFrame
......................

DefaultTableModel model=new DefaultTableModel();
TableColumn col;

table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setModel(model);
model.addColumn("TNAME");
model.addColumn("TABTYPE");
model.addColumn("CLUSTERID");

col=table.getColumnModel().getColumn(0);
col.setPreferredWidth(300);
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On