AWT components in java
The choice control contains a list of choices from which one can be selected. When it is inactive it takes the same Space as that of a single choice. Choice has only one default constructor, namely:
Choice choice1 = new Choice();
Here choice1 is the object name, the programmer can give the desired name as the object name.
To add items to the choice created in the above statement, The following method can be used.
choice1.addltem(String);
choice1.add(String);
To get the selected item, the method getSelected Item() is used and the index of the Selected item can be obtained using the method get selectedindex().
Items can also be selected using Select( int index) and Select (String name) when either the index or the name of the item is Known.
List control.
The list control is similar to the choice control, but multiple items can be selected using the list control.Here the number rows to be visible in the list can be specified, Whereas in the choice cotrol only one choice is visible in the inactive state.The type of constructor Supported by List cotrols are:
List list1=new List();
List list2=new List(int);
List list3=new List(int,boolean);
Here list1, list2 and list3 are the object name, the programmer can give the desired name as the object name.
The first Constructor is the default list. The Second specifies the number of rows to be visible in the list and The third constructor Specifies whether the multiple selections can be made.The methods that are used to add and Select an item to the list are the same as those of Choice.
Important questions and answers in java AWT:
1 ActionListener handles the event that occurs when a button is pressed.
2 The Component classes cannot be instantiated
3 The applet class is a subclass of Panel
4 The panel class is a subclass of Container
5 The LayoutManager is a Interface
6 The default layout manager for panel is FlowLayout
7 A pixel is a display monitor’s smallest unit of resolution.AWT controls in Java-Beginners note-part 1
ReplyDeleteThanks for sharing! To learn more about how Java microservices help with Migrate Monolithic to Microservices
Thanks for sharing this informative post! It’s always great to explore more about Java programming. I also found this article on top data engineering companies for 2025 insightful—it could help take your projects to the next level with advanced solutions.
ReplyDelete