Resizing JTable Columns in Netbeans

R

R^3

I would like to change the width of columns in a JTable. I know I have
some working code to do this, but I don't know *where* in Netbeans to
put it, and how to preview it.

Code:

TableColumn tableColumn = jTable1.getColumnModel().getColumn(1);
tableColumn.setMinWidth(240);
tableColumn.setPreferredWidth(240);
tableColumn.setMaxWidth(240);
jScrollPane2.setViewportView(jTable1);

I have tried putting this in the "postcreation code" and the "post
initialization code" but whenever I preview it, there is no change to
the JTable. How can I get this to work?

Ryan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top