Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Swing "Menu Bar" on "Window Component"!

Posted on 2011-09-22
24
Medium Priority
?
620 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
[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
  • 10
  • 9
  • 2
24 Comments
 
LVL 86

Expert Comment

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

Author Comment

by:snajalm
ID: 36579024
This is what I mean by Window Component!

Thanks

The Window Component
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36579054
That doesn't answer my question ;) Basically only JApplet or JFrame can have menu bars afaicr
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:snajalm
ID: 36579355
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
ID: 36579434
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
ID: 36579493
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
ID: 36579980
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
ID: 36580143
Make sure you've not set the wrong frame as your main application window
0
 

Author Comment

by:snajalm
ID: 36580554
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
ID: 36580675
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 1000 total points
ID: 36580693
Make sure the class 'Gimp' is set in the project properties as the main class
0
 

Author Comment

by:snajalm
ID: 36580844
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
ID: 36580857
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 1000 total points
ID: 36585133
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
ID: 36585137
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
ID: 36708307
I've requested that this question be deleted for the following reason:

No clear solution was proposed!
0
 
LVL 86

Expert Comment

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

Author Comment

by:snajalm
ID: 36813026
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
ID: 36813478
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
ID: 36935587
Yes - so far i've receivedno response
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36948843
:)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

636 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