Solved

How to disable JTable column dragging?

Posted on 2000-04-29
7
1,606 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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)
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

861 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

24 Experts available now in Live!

Get 1:1 Help Now