How to resize table columns separately using NetWeb GUI Builder?

When creating a quick project layout using NetBeans GUI Builder, I had a problem with the parameters provided to me for the Table object. It seems that I can not resize the columns separately, but only the entire table. I'm wrong, and is there a way to resize columns using the GUI Builder? If not, can I accomplish this with Swing code? How?

+6
java swing netbeans jtable
source share
2 answers

SInce default JColumnModel created by the creator of the NetBeans GUI is hidden and cannot be configured in the Property plalette, you will have to do this programmatically.

Go to the "Original view" (there is a small button above the editor area to switch between the "Original view" and "Design view"), and put the following code in the constructor

 /** Creates new form NewJFrame */ public NewJFrame() { initComponents(); // Insert this line into your code jTable1.getColumnModel().getColumn(0).setPreferredWidth(20); } 

For more information read here or google for "jtable column size".

Here is another useful information.

+8
source share

For those who are still looking for an answer that finds this message, the selected answer is not the right way to do this from the Netbeans GUI.

As said in one of the answers here (Heater Buch), to change the column width:

  • In design mode, right-click on the table;
  • Select "Table Contents ..." and the Customizer dialog box appears.
  • Go to the "Columns" tab, and there you can set several properties, including preferred / minimum / maximum width.
+3
source share

All Articles