Solved

No event is fired after clicking menuitem

Posted on 2012-03-22
3
514 Views
Last Modified: 2012-03-22
I used netbeans to create my application ..my application contains a frame 'MainPage' with a menu bar.It has menu 'Records' .. 'Records' contain 'Order' as menu item ...
i applied action event on Order(menuitem) to open an internal frame with name Order..
I know that JInternal frame has to be placed on a Desktop pane so i have written a code for that but when i click on menu item(Order) the Order JInternal Frame doesnt appear..
Attaching my code below ..pls go through it and help me solve the issue..
mainpage.txt
Order.txt
0
Comment
Question by:daydreamer6565
3 Comments
 
LVL 7

Expert Comment

by:gudii9
ID: 37754944
0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 37755131
Don't know about InternalFrame - that would be your next probalem
As of now your actionListener simplye does not work
(jaust add System.out.println("ttt2");
as fisrt line in actionPerforemd - and you will not see it printed before any JInternalFrame


  orderMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                System.out.println("ttt2");
                orderMenuItemActionPerformed(evt);
            }
        });

Open in new window


The reason for taht is that you orderMenuItem is declared as JMenu, not JMenuItem
ok at the bottom of your main:
 private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenu orderMenuItem;// wrong - should be JMenuItem type, not JMenu
    private javax.swing.JMenu recordsMenu;
    private javax.swing.JMenu reportsMenu;
    // End of variables declaration

Open in new window


Change that type to JMenuItem and you'll see that
it will print tttt2 - listener will be working
0
 

Author Closing Comment

by:daydreamer6565
ID: 37755856
Oh yes ...I by mistakely selected menu insted of menuitem in the design...
Thanks nw its working :D
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
table example 4 32
how to see all occupied ports on windows 10 laptop 15 76
how to install java on RHEL image on EC2 4 40
sql import cannot be resolved jsp 3 47
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

856 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