What is the difference between itemlistener and actionlistener




















As you can see from the previous section, a check box can have 2 types of event listensers: ActionListener and ItemListener. The following sample program shows you when those listeners are called, and how many times:.

This example program creates a combo box with 3 options. It has 2 listeners to handle 2 different types of events. A counter is used in the listener class to help to identify the order of events. If you run this program, you will see a combo box with 3 options: "Red", "Green" and "Blue".

By default, the first option will be selected. But I called the setSelectedIndex -1 to removed the selection. If you open the drop-down list, you see messages 1 and 2. Share this: Twitter Facebook. Like this: Like Loading Leave a Reply Cancel reply Enter your comment here Fill in your details below or click an icon to log in:.

Email Address never made public. Blog Stats , hits. Search for:. Follow Following. GeekyCoder Join 33 other followers. Sign me up. Already have a WordPress. Log in now. Luke on Java Tips: Disabling the maxim…. FunzSquare on Getting your game console in S…. Python Javascript Linux Cheat sheet Contact. For reference, here's an sscce that illustrates the difference. EventQueue; import java. ActionEvent; import java. ActionListener; import java.



0コメント

  • 1000 / 1000