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
Solved

Swing "Menu Bar" on "Window Component"!

Posted on 2011-09-22
24
602 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
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 58
JAVA API design with micro service cloud in mind 1 45
jmss example java 2 23
Tagging and Merging on Branch 1 29
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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…

839 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