The Artima Developer Community
Sponsored Link

Java Answers Forum
how can I set up a JTable so that the user cannot move the columns around?

8 replies on 1 page. Most recent reply: Jul 8, 2002 6:45 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 8 replies on 1 page
john

Posts: 10
Nickname: swing
Registered: Jul, 2002

how can I set up a JTable so that the user cannot move the columns around? Posted: Jul 2, 2002 9:27 AM
Reply to this message Reply
Advertisement
Is there a way in which I can prevent a user from dragging the columns in a JTable around?


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: how can I set up a JTable so that the user cannot move the columns around? Posted: Jul 2, 2002 3:02 PM
Reply to this message Reply
setDragEnabled to false

yourJTableName.setDragEnabled(false);

john

Posts: 10
Nickname: swing
Registered: Jul, 2002

Re: how can I set up a JTable so that the user cannot move the columns around? Posted: Jul 3, 2002 11:07 AM
Reply to this message Reply
Thanks there, but what class of member function is setDragEnabled(boolean flag)? Compiler gave me error message "setDragEnabled(boolean flag) is not found in class java.swing.JTable".

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: how can I set up a JTable so that the user cannot move the columns around? Posted: Jul 3, 2002 3:25 PM
Reply to this message Reply
Please follow the following link:

http://java.sun.com/j2se/1.4/docs/api/javax/swing/JTable.html#setDragEnabled(boolean)

john

Posts: 10
Nickname: swing
Registered: Jul, 2002

Re: how can I set up a JTable so that the user cannot move the columns around? Posted: Jul 4, 2002 12:27 AM
Reply to this message Reply
I used jdk1.3.0....

Thanks a lot

akim

Posts: 12
Nickname: akim
Registered: Jul, 2002

Re: how can I set up a JTable so that the user cannot move the columns around? Posted: Jul 4, 2002 12:51 AM
Reply to this message Reply
used jdk1.3.1

john

Posts: 10
Nickname: swing
Registered: Jul, 2002

Re: how can I set up a JTable so that the user cannot move the columns around? Posted: Jul 8, 2002 10:15 AM
Reply to this message Reply
I installed the jdk1.4.0_01. The program was compiled successfully with the extra line code "mytable.setDragEnabled(false)", but the column in the table still could be moved around! If there is something else needed to be changed as well?

Thank you.

john

Posts: 10
Nickname: swing
Registered: Jul, 2002

Re: how can I set up a JTable so that the user cannot move the columns around? Posted: Jul 8, 2002 4:50 PM
Reply to this message Reply
Finally I got it work with following code:

myJTable.getTableHeader().setReorderingAllowed(flase);


Thanks again

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: how can I set up a JTable so that the user cannot move the columns around? Posted: Jul 8, 2002 6:45 PM
Reply to this message Reply
I'm surprised that works. I usually have trouble getting that pesky flase option to function properly. ;-)

Flat View: This topic has 8 replies on 1 page
Topic: Please help me to understand my Java assignment Previous Topic   Next Topic Topic: Java 1.4 Platform Certification Exam

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use