?
Solved

How to disable JTable column dragging?

Posted on 2000-04-29
7
Medium Priority
?
1,891 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
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:
Suggested Courses

649 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