Solved

Swing "Menu Bar" on "Window Component"!

Posted on 2011-09-22
24
605 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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 250 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 250 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

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

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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 synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

688 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