This section describes, how to move a column in JTable component. Moving is a very simple method that moves the data from one position to the other. If you want to move a column from one position to another specified position in JTable via using the moveColumn() method, you need the index of column that will count from '0' which denotes the first column of JTable. The moveColumn method takes the index of columns.
Description of program:
This program helps you in moving a column into JTable. This program creates a table through the JTable having '4' rows and '3' columns with the column header and yellow background color in it. This program uses the move method to move a column at specified position with the help of moveColumn() method. In the first table, the previous column is Name, secondary is Course and the third one is Subject. After moving, Course reaches on the first position, Name goes to the second position and Subject does not left it's position So you can see how the first column moves from first position to second position.
Here is the code of program:
Output of program:
After moving a column:
Posted on: April 14, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles