In this section, you will learn how to change the name of column in JTable component. You have learnt the JTable containing some data and column with column headers. Sometime, if you want to change the name of column, you must have to change the column header. For changing the name of column, you will need the index of column. Here, you will learn how to change the name in the name of column in a JTable in this following example.
Description of program:
This program helps you to change the name of column in JTable. For changing the name, you will need a table and column index that have to be changed.. Here the ChangeName method is applied to change the name of column in JTable that uses the getColumnModel, getColumn and setHeaderValue methods. After this you will get the changes column name [Name - Stu_name, Subject - Paper]. As look like the given output.
Description of code:
This is the method that sets the object (column name) to use as headerRenderer. It takes an object parameter that is the name of column in string format.
Here is the code of program:
Output of program:
Before changing the name of column:
After changing the name of column:
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: Changing the Name of Column in a JTable
Post your Comment