Solved

JTable column problem

Posted on 2004-09-13
3
652 Views
Last Modified: 2008-02-01
My program use JTable to show information in form of table.

Is it possible to disable column swapping feature such that user can only resize the column size, but he/she cannot swapping the columns (eg. swapping column one to column four by drag-and-drop). How to achieve it ?

Thanks.........
0
Comment
Question by:glogin
[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
3 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 50 total points
ID: 12041827
Try:

JTable.getTableHeader().setReorderingAllowed(false);
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12041840
For restricting column movement use
    table.getTableHeader().setReorderingAllowed(false);

For restricting column resizing use
    table.getTableHeader().setResizingAllowed(false);

For individual column resizing use
    table.getColumnModel().getColumn(index).setResizable(false/true);

    NOTE:This does not work (due to a feature) prior to the Java 2 Platform, Standard Editiion, version 1.3 (Kestrel).

0
 
LVL 37

Expert Comment

by:zzynx
ID: 12041843
JTableHeader.setReorderingAllowed(boolean reorderingAllowed)

          Sets whether the user can drag column headers to reorder columns.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.

696 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