Solved

No event is fired after clicking menuitem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PDFBox - convert image to PDF, PDF resolution 3 117
The line on IDE 4 69
Problem to start Neon 20 87
difference of if loops 23 41
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
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…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

920 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

14 Experts available now in Live!

Get 1:1 Help Now