Solved

Swing "Menu Bar" on "Window Component"!

Posted on 2011-09-22
24
599 Views
Last Modified: 2012-06-22
I'm trying to add a "menu bar" to a "Window Component" within my Netbeans platform module.  I do not seem to be able to do that whereas this is possible within JFrame.  The "Window component" can take other Swing components and containers but apparently not the "Swing Menus".
0
Comment
Question by:snajalm
  • 10
  • 9
  • 2
24 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
What Java type is this 'Window Component'? Only top level windows can have menus
0
 

Author Comment

by:snajalm
Comment Utility
This is what I mean by Window Component!

Thanks

The Window Component
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
That doesn't answer my question ;) Basically only JApplet or JFrame can have menu bars afaicr
0
 

Author Comment

by:snajalm
Comment Utility
OK then how can I make the Window component take advantage of the JFrame when I can have my menu bar there??!  I tried attaching the JFrame to my module but when I compile it the JFrame does not launch for some reason and that's why I'm using the Window Top component where it launches on startup!
0
 

Author Comment

by:snajalm
Comment Utility
Basically if I could get the JFrame to launch on application start, I'd be willing to use that instead!
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Well as i mentioned before, you generally only want one JFrame per app, so you would put the menu on the main application window. Are you saying you can't do that for some reason?
0
 

Author Comment

by:snajalm
Comment Utility
Yes, when I link a JFrame to my module and add my containers and components to it, none of the items I added to the JFrame show up when I run my application!  I can't tell where the problem could be or if I'm missing any logical concept behind the JFrame not showing anything at run time!
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Make sure you've not set the wrong frame as your main application window
0
 

Author Comment

by:snajalm
Comment Utility
How can I make a frame my main application window though?!  I'm new to Netbeans and that's why this question might sound a bit newbie!
0
 

Author Comment

by:snajalm
Comment Utility
And there is only one frame I'm using and nothing else!  

This is my constructor which is seemingly being initialized.

public Gimp() {
        initComponents();
}

And the following is my main method if it could help!

    public static void main(String args[]) {
   
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(IdaMainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(IdaMainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(IdaMainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(IdaMainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new IdaMainWindow().setVisible(true);
            }
        });
    }
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
Comment Utility
Make sure the class 'Gimp' is set in the project properties as the main class
0
 

Author Comment

by:snajalm
Comment Utility
I can't find an option under Project properties that allows me to pick my main class.  Can you please be more specific??!
0
 

Author Comment

by:snajalm
Comment Utility
I would be grateful if you run me through it since this problem has been stopping me for long!
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 250 total points
Comment Utility
In NetBeans to set the main class you right-click the project in
left column (project browser), select "Set Configuration"-customize - you'll see new window, then
 select Run in the left column of this window - and on the right side you can specify
main class, arguments of VM and of yoour application, etc,.
0
 
LVL 47

Expert Comment

by:for_yan
Comment Utility
This example shows how to create menu bar on JFrame:

http://www.java-tips.org/java-se-tips/javax.swing/how-to-create-menu-bar.html
0
 

Author Comment

by:snajalm
Comment Utility
I've requested that this question be deleted for the following reason:

No clear solution was proposed!
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
A clear solution WAS proposed - why are you attempting to close this?
0
 

Author Comment

by:snajalm
Comment Utility
I believe that the instructions given did not answer my question since my problem is solely in regards to "Netbeans Platform" which is sometimes mistaken by any ordinary project under Netbeans.  When you link your "module" to a "Window" component you cannot utilize MenuBars and when you link JFrame to your main "module" you can not get it to launch on application start.  I can give points to CEHJ for mentioning that MenuBars can only be used within JFrame and JApplet but I still need to know how would I get JFrame to load on application start with "Netbeans Platform" which is apparently a new technology!

Regards
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
OK. Let me suggest that you zip the project and place it somewhere i can download and examine it.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Yes - so far i've receivedno response
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

771 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

13 Experts available now in Live!

Get 1:1 Help Now