Solved

No event is fired after clicking menuitem

Posted on 2012-03-22
3
515 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 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

740 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