title: JXTable: how to query state on column models?
body: <p>I am writing some UI persistence methods for an application. I'm trying to expand to a JXTable with a fixed set of N columns in the table model.</p>
  <p><strong>How can I get and set the following information for column #k in the JXTable, where k is the column number in table model order?</strong> It's not as easy as it sounds, or at least I'm missing some tricky bit of information.</p>
  <ul>
  <li>column width</li>
  <li>column visibility</li>
  <li>column order</li>
  </ul>
  <p><a href="http://www.jarvana.com/jarvana/view/org/swinglabs/swingx-core/1.6.2/swingx-core-1.6.2-javadoc.jar!/org/jdesktop/swingx/table/TableColumnModelExt.html#getColumns%28boolean%29" rel="nofollow noreferrer"><code>TableColumnModelExt.getColumns()</code></a> includes this crazy note, which I'm having trouble parsing:</p>
  <blockquote>
  <p><code>java.util.List&lt;javax.swing.table.TableColumn&gt; getColumns(boolean includeHidden)</code></p>
  <p>Returns a List of contained TableColumns. Includes or excludes invisible columns, depending on whether the includeHidden is true or false, respectively. If false, an Iterator over the List is equivalent to the Enumeration returned by getColumns().</p>
  <p>NOTE: the order of columns in the List depends on whether or not the invisible columns are included, in the former case it's the insertion order in the latter it's the current order of the visible columns.</p>
  </blockquote>
  <p>Also, I know how to use <a href="http://docs.oracle.com/javase/6/docs/api/javax/swing/JTable.html#convertColumnIndexToView%28int%29" rel="nofollow noreferrer"><code>JTable.convertColumnIndexToView()</code></a>, but it returns -1 for hidden columns, and leaves no information about which order the hidden column would go if it were made visible again. JXTable knows this information because you can restore column visibility, and it puts the column where it was before it was hidden.</p>