In this Java programming section, you will learn how to create a scrollable JTable component. When any table has large volume of data, the use of scrollbar is applied in the JTable. The JScrollPane provides you to scrollable facility to scroll the scroll bar and you get all the contents.
Description of program:
The following program helps you to create a scrollable JTable. First of all, this program creates a table having the large amount of data and columns with column header. The JScrollPane provides the facility for looking its data by scrolling the scroll bar either horizontal or vertical or both. The auto resize mode property of JTable is true by default so, it couldn't be scrollable. To use the scrollable property of table first remove the auto resize mode property then use the scrollable property.
Description of code:
setAutoResizeMode(int mode):
This is the method to sets the auto resize mode of JTable for resizing the JTable. It takes the following specified integer type values:
Here is the code of program:
import javax.swing.*;
|
Output of program:
![]() |
|
Recommend the tutorial |

Ask Questions? Discuss: Creating a Scrollable JTable View All Comments
Post your Comment