Solved

item label components

Posted on 2006-11-04
9
183 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 92

Expert Comment

by:objects
ID: 17875095
yes thats fine
0
 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL  on Tomcat 8 68
spring jars download 1 35
difference between sorce folder and folder in eclipise 3 29
eclipse console opening separately 2 29
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

828 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