Solved

No event is fired after clicking menuitem

Posted on 2012-03-22
3
511 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

705 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

18 Experts available now in Live!

Get 1:1 Help Now