• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 666
  • Last Modified:

JTable column problem

My program use JTable to show information in form of table.

Is it possible to disable column swapping feature such that user can only resize the column size, but he/she cannot swapping the columns (eg. swapping column one to column four by drag-and-drop). How to achieve it ?

Thanks.........
0
glogin
Asked:
glogin
1 Solution
 
girionisCommented:
Try:

JTable.getTableHeader().setReorderingAllowed(false);
0
 
armoghanCommented:
For restricting column movement use
    table.getTableHeader().setReorderingAllowed(false);

For restricting column resizing use
    table.getTableHeader().setResizingAllowed(false);

For individual column resizing use
    table.getColumnModel().getColumn(index).setResizable(false/true);

    NOTE:This does not work (due to a feature) prior to the Java 2 Platform, Standard Editiion, version 1.3 (Kestrel).

0
 
zzynxSoftware engineerCommented:
JTableHeader.setReorderingAllowed(boolean reorderingAllowed)

          Sets whether the user can drag column headers to reorder columns.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now