Reputation: 1
I'm trying to create a simple GUI with a menu bar at the top of the jwindow using java. I'm able to get the menu bar to show and I'm able to implement the actionlistener class, however, how do I get the ok and ye tab, once clicked, to print out information? In other words how do I use the actionlistener class to create an action to print information out once ok or ye has been clicked by the user?
// Creates a menu bar
z.setJMenuBar(b);
File.add(ok);
File.add(ye);
Help.add(laws);
bar.add(HELP);
bar.add(FILE);
// Listener objects created
ok.addActionListener(this);
ye.addActionListener(this);
Upvotes: 0
Views: 383
Reputation: 39164
if you are adding this like action listener the you should implement abstract method actionPerformed. You can do everything inside that method.
Upvotes: 1