TRUE or FALSE

1: You can register an Action Listener to a JFrame

2: An ItemEvent is generated only when a user clicks a UI component

ENUMERATION:

3: Why don’t ItemListener and ActionListener have adapter classes




1: The answer is True.
We Can do this by using.

Public void actionPerformed(ActionEvent e) {
         numClicks++;
         text.setText("Button Clicked " + numClicks + " times");

2.) False

A semantic event indicates that an item was selected or deselected. This high-level event is generated by an ItemSelectable object (such as a List) when an item is selected or deselected by the user. The event is passed to every ItemListener an object which registered to receive such events using the component's addItemListener method.

3:) Item events are fired by components that implement the ItemSelectable interface. Generally, ItemSelectable components maintain on/off state for one or more items. The Swing components that fire item events include buttons like checkboxes, check menu items, toggle buttons, etc...and combo boxes.

The ItemListener Interface

Because ItemListener has only one method, it has no corresponding adapter class.

So there isn't an ActionAdapter, because the ActionListener interface only has one method. But you can always make your own ActionAdapter if you so wish.

Example one: You have a DisplayPanel called panel, and you want to display the mouse position on a JTextField on the display panel. If you don't use a MouseMotionAdapter, you get the display panel to implement the MouseMotionListener interface, which has two methods.

Comments

Popular posts from this blog

Create and outline the timeline of History of Operating Systems.