Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 JMenu Bar
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
yumrum




PostPosted: Sat Apr 16, 2011 11:21 pm   Post subject: JMenu Bar

For our year end project we have to make a search Database program and my user interface has a JMenu at the top and i was wonder if there is a way to make the top button- do an action.

What i mean is if the menu looked like the below example i want is so that if you push the original instructions the instruction pane would be created right away but right now i can only do that from the drop down thing from instructions... Like you click it and then you have to click it again below which just seems useless and stupid.

Anyway If anyone could help me with the command i need for action performed to make this work it would be great.

File Instructions Options File Instructions Options
\/
Instructions
Sponsor
Sponsor
Sponsor
sponsor
deltamanx




PostPosted: Mon Apr 25, 2011 9:12 pm   Post subject: Re: JMenu Bar

The JMenu Bar
code:

JFrame f = new JFrame("Frame");
JMenuBar menuBar = new JMenuBar();
f.setJMenuBar(menuBar);
JMenu menu = new JMenu("Menu");
menuBanr.add(menu);
JMenuItem item = new JMenuItem("Click Me");
menu.add(item);
item.addActionListener(this); //Your class must implement ActionListener
f.setVisible(true);


The event:
code:

public void actionPerformed(ActionEvent ae)
{
  if(ae.getActionCommand().equals("Click Me"))
    System.out.println("You clicked me");
}
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: