Solved

JTable column problem

Posted on 2004-09-13
3
644 Views
Last Modified: 2008-02-01
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
Comment
Question by:glogin
3 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 50 total points
Comment Utility
Try:

JTable.getTableHeader().setReorderingAllowed(false);
0
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
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
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
JTableHeader.setReorderingAllowed(boolean reorderingAllowed)

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now