Solved

How to disable JTable column dragging?

Posted on 2000-04-29
7
1,560 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

708 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

12 Experts available now in Live!

Get 1:1 Help Now