In this section, you will learn about setting the dimensions of the List component in java. A list can have multiple data or items. Here, you will know how to set data or items in a List Component. This provides setting the dimension of items present in the list. You can specify the dimension of items present in the list.
Here, the dimension for the items of the list have been mentioned according to the length of the specified text "Roseindia.net". The These are shown in the following figure:
Following are the explanation of the used method which is helpful for setting the dimension of various items of the list:
This method sets the dimension of the list items. This method takes a string as a parameter. According to the length of the mentioned string, all the list width is arranged properly.
Here is the code of program:
Liked it! Share this Tutorial