Solved

How to disable JTable column dragging?

Posted on 2000-04-29
7
1,639 Views
Last Modified: 2008-03-10
I'm using a JTable and the user can drag columns this way changing column ordering. I want to disable it. Please provide a few lines of code which does it.

Thanks.
0
Comment
Question by:Mindo
7 Comments
 

Expert Comment

by:bhardwajanjali
ID: 2761875
I am ot sure what are you asking but may be the following exception helps you.
I think you want to disble the column drag property of the table. See if you want to drag a table first you need to select it and then onle you can drag it.
So why dot you try to disable the selection of the column using the following function:
void setColumnSelectionAllowed(boolean flag)

Hope this helps.

cheers,
Anjali
0
 

Expert Comment

by:bhardwajanjali
ID: 2761876
I am not sure what are you asking but may be the following discussion helps you.
I think you want to disable the column drag property of the table. See if you want to drag a table first you need to select it and then only you can drag it.
So why dot you try to disable the selection of the column using the following function:
void setColumnSelectionAllowed(boolean flag)

Hope this helps.

cheers,
Anjali
0
 
LVL 2

Author Comment

by:Mindo
ID: 2761884
You didn't understand point. The user drags the column by clicking on the column header and dragging mouse. Then the user can release the mouse and the column order changes, i.e. the column is dragged to another place.

Try it using JTable and you'll understand how columns can be dragged.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 3

Expert Comment

by:terajiv
ID: 2761947
Hi Mindo,
The following method may help u
void                 setColumnSelectionAllowed(boolean flag)

Rajiv
0
 
LVL 2

Author Comment

by:Mindo
ID: 2762020
This question isn't about column selection, it's about column DRAGGING. Please, try a simple example and you'll see how the user can drag a column from one place to another. What does it have to do with column selection?
0
 
LVL 19

Accepted Solution

by:
Jim Cakalic earned 50 total points
ID: 2762045
Column reordering is a behavior implemented by JTableHeader. Try this:

    JTable table = <your table>;
    table.getTableHeader().setReorderingAllowed(false);

Best regards,
Jim Cakalic
0
 
LVL 2

Author Comment

by:Mindo
ID: 2762066
Works cool, thanks.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Image decoding from Camera 3 85
rhino JavaScript import, load 25 82
spring jars download 1 26
throw exception 21 42
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
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 …

813 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

17 Experts available now in Live!

Get 1:1 Help Now