Solved

item label components

Posted on 2006-11-04
9
181 Views
Last Modified: 2010-03-31
can someone show me how to format the the item label components

//////// item.addActionListener(new ActionListener() {
/////     public void actionPerformed(ActionEvent e) {
//////     }
//////   });  

       FlowLayout layout7 = new FlowLayout(FlowLayout.CENTER);
          File7.setLayout(layout7);
               menuBar = new JMenuBar();
           JMenu menu = new JMenu("Menu");
               JMenuItem item = new JMenuItem("Item Label");
            setJMenuBar(menuBar);
                    ////////////////////////////  item.addActionListener(actionListener);
                   File7.add(menu);
                   menu.add(item);
            pane.add(File7);
      setVisible(true);
0
Comment
Question by:charliebaby
  • 5
  • 4
9 Comments
 

Author Comment

by:charliebaby
ID: 17874877
I'm really grasping at straws, cannot find the combonation that activates the menu select  fuction("item label"), anything would be a help.
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 17874910
item.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent event) {
       // this will get called
}});
0
 

Author Comment

by:charliebaby
ID: 17874942
So were exactualy should I place ,item.addActionListener(actionListener);


FlowLayout layout7 = new FlowLayout(FlowLayout.CENTER);
          File7.setLayout(layout7);
               menuBar = new JMenuBar();
           JMenu menu = new JMenu("Menu");
               JMenuItem item = new JMenuItem("Item Label");
            setJMenuBar(menuBar);
                   File7.add(item);
                   File7.add(menu);
                   menu.add(item);
                    pane.add(File7);
                  item.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
  }
});  
setVisible(true);
     }
0
 
LVL 92

Expert Comment

by:objects
ID: 17875095
yes thats fine
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:charliebaby
ID: 17875155
Yes it is only that I cannot get,  item.addActionListener(actionListener); , to compile is there some thing wrong with it?
0
 
LVL 92

Expert Comment

by:objects
ID: 17875223
yes, you don't define the var actionListener anywhere
0
 

Author Comment

by:charliebaby
ID: 17875243
var ActionListener=java.awt.event.ActionListener; how do I define this and do I have to add "var" to  item.add varActionListener(actionListener); I am so confused please spell it out for me and I will close out the question, Thank you
0
 
LVL 92

Expert Comment

by:objects
ID: 17875338
you don't need that line, it can be replaced with what i posted above
0
 

Author Comment

by:charliebaby
ID: 17876616
well I did what you say, so I will close the question like I said I would, however  JMenuItem item = new JMenuItem("Item Label"); I don't see the menu chioce.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now