In this section, you will learn how to set an icon with text in a column head of JTable component. But what is icon?
Icon: This is a graphical user interface (GUI). An image or picture available on the screen that helps you to identify file, folder, directory and window etc.
Description of program:
First of all this program creates a JTable containing some data and column with column header. After that you will set the icons in column header. For this you will need an image or icon that have '.gif' extension. Here you will see the SetIcon method applied for setting the icon with text in column header. This method uses the setHeaderRenderer and setHeaderValue methods that helps you setting the icon and text in column header. After doing entire process, you will get the first and second column header having icon with text.
Description of code:
This is the method that is used to set the given text in specified location.
This method helps you to set the given icon on the specified location.
Here is the code of program:
Output of program:
Before setting an icon:
After setting an icon with text:
Posted on: April 14, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles