?
Solved

No event is fired after clicking menuitem

Posted on 2012-03-22
3
Medium Priority
?
518 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 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