On Sep 24, 1:04 am, Victor Lutin <umg.victor.lu...@gmail.com> wrote:
> Mmmh ... You can add an ActionListener directly to MenuItem, You don't need
> to use a JButton for that.
>
> Check Java Doc:
>
> http://java.sun.com/j2se/1.4.2/docs/api/java/awt/MenuItem.html
>
> This works in 1.4+ :) ...
>
> Your class most implements ActionListener Interface
>
> public class YourClasssWithMenuItems implements *ActionListener* {
> private JMenuItem item1;
> :
> *public void actionPerformed(ActionEvent a)* {
> if(a.getSource() == item1) { // MenuItem 1 has an action event.
> :
> }
> :
> }
> :
> item1 = new JMenuItem("Item 1");
> item.addActionListener(this);
> :
>
Thanks for this. However, the program in some cases will work as
follows:
Click JMenuItem -> Display a JList -> Select an item from JList ->
Display a new window, in this new window I need to check which
JMenuItem I was clicked. I still don't know how to work.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---