You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Zulfi Khan <zu...@yahoo.com.INVALID> on 2022/03/16 00:01:49 UTC

JMenu: Can't see the output window

 
The output GUIsticks to the NetBeans window. I can’t see the output window. I have attached the image. Somebbody please guide me.





The steps of thedevelopment are as follows:




1. Add a JFrame Formclass by right clicking on the name of the application

2.Click on theJframe Form class just added.

3. It would show theSource and Design menu items.

4. Click on thedesign menu item

5. It open thepalette.

6. Click on theswing menus in the palette

7. Drag the 'menubar' from the swing menu options and put it on top of the JFrameForm class file. We will see the originalsquare box of the JFrameform class with the menu bar lying on top of it. Menu bar has optionsFile and Edut. This process is called adding a JMenuBar to a JFrame.

8. Next step is toadd Jmenus to JMenuBar

9. Drag Jmenu andplace it on the File menu. File menu will be enclosed in square box.This means that the menu has been well placed.

10. Next add JMenuItem to the JMenu

11. Run theapplication







The code is givenbelow:

/*

 * Clicknbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txtto change this license

 * Clicknbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to editthis template

 */

packagecom.mycompany.menugui;




/**

 *

 * @author zulfi

 */

public classMenuGuiForm extends javax.swing.JFrame {




 /**

 * Creates newform MenuGuiForm

 */

 publicMenuGuiForm() {

 initComponents();

 }




 /**

 * This methodis called from within the constructor to initialize the form.

 * WARNING: DoNOT modify this code. The content of this method is always

 * regeneratedby the Form Editor.

 */

 @SuppressWarnings("unchecked")

 // <editor-folddefaultstate="collapsed" desc="Generated Code"> 

 private voidinitComponents() {




 jMenuItem1 =new javax.swing.JMenuItem();

 jMenuBar1 =new javax.swing.JMenuBar();

 jMenu1 = newjavax.swing.JMenu();

 jMenu3 = newjavax.swing.JMenu();

 jMenu2 = newjavax.swing.JMenu();




 jMenuItem1.setText("jMenuItem1");




 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);




 jMenu1.setText("File");




 jMenu3.setText("jMenu3");

 jMenu1.add(jMenu3);




 jMenuBar1.add(jMenu1);




 jMenu2.setText("Edit");

 jMenuBar1.add(jMenu2);




 setJMenuBar(jMenuBar1);




 javax.swing.GroupLayout layout = newjavax.swing.GroupLayout(getContentPane());

 getContentPane().setLayout(layout);

 layout.setHorizontalGroup(

 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

 .addGap(0, 400, Short.MAX_VALUE)

 );

 layout.setVerticalGroup(

 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

 .addGap(0, 275, Short.MAX_VALUE)

 );




 pack();

 }//</editor-fold> 




 /**

 * @param argsthe command line arguments

 */

 public staticvoid main(String args[]) {

 /* Set theNimbus look and feel */

 //<editor-fold defaultstate="collapsed" desc=" Lookand feel setting code (optional) ">

 /* If Nimbus(introduced in Java SE 6) is not available, stay with the defaultlook and feel.

 * Fordetails seehttp://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

 */

 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(MenuGuiForm.class.getName()).log(java.util.logging.Level.SEVERE,null, ex);

 } catch(InstantiationException ex) {

 java.util.logging.Logger.getLogger(MenuGuiForm.class.getName()).log(java.util.logging.Level.SEVERE,null, ex);

 } catch(IllegalAccessException ex) {

 java.util.logging.Logger.getLogger(MenuGuiForm.class.getName()).log(java.util.logging.Level.SEVERE,null, ex);

 } catch(javax.swing.UnsupportedLookAndFeelException ex) {

 java.util.logging.Logger.getLogger(MenuGuiForm.class.getName()).log(java.util.logging.Level.SEVERE,null, ex);

 }

 //</editor-fold>




 /* Createand display the form */

 java.awt.EventQueue.invokeLater(new Runnable() {

 publicvoid run() {

 newMenuGuiForm().setVisible(true);

 }

 });

 }




 // Variablesdeclaration - do not modify 

 privatejavax.swing.JMenu jMenu1;

 privatejavax.swing.JMenu jMenu2;

 privatejavax.swing.JMenu jMenu3;

 privatejavax.swing.JMenuBar jMenuBar1;

 privatejavax.swing.JMenuItem jMenuItem1;

 // End ofvariables declaration 
}
Zulfi.


Re: JMenu: Can't see the output window

Posted by Ernie Rael <er...@raelity.com>.
I copied the file from your email into an empty project. Right click in 
the file and select "Run File". A JFrame with menu bar (as shown in your 
gui builder) was displayed in the upper left corner. To simplify things, 
you can click on "Source" in the editor toolbar window, and just display 
the source code, then do the "Run File"

There's also terminology issue. NetBeans has an "Output Window" which 
you can see at the bottom of your image. I would call the JFrame, that 
you want to see displayed, your programs "Main Window".

HTH,
-ernie

On 3/15/22 5:01 PM, Zulfi Khan wrote:
>
> The output GUI sticks to the NetBeans window. I can’t see the output 
> window. I have attached the image. Somebbody please guide me.
>
>
> The steps of the development are as follows:
>
>
> 1. Add a JFrame Form class by right clicking on the name of the 
> application
>
> 2.Click on the Jframe Form class just added.
>
> 3. It would show the Source and Design menu items.
>
> 4. Click on the design menu item
>
> 5. It open the palette.
>
> 6. Click on the swing menus in the palette
>
> 7. Drag the 'menu bar' from the swing menu options and put it on top 
> of the JFrame Form class file. We will see the originalsquare box of 
> the JFrame form class with the menu bar lying on top of it. Menu bar 
> has options File and Edut. This process is called adding a JMenuBar to 
> a JFrame.
>
> 8. Next step is to add Jmenus to JMenuBar
>
> 9. Drag Jmenu and place it on the File menu. File menu will be 
> enclosed in square box. This means that the menu has been well placed.
>
> 10. Next add JMenu Item to the JMenu
>
> 11. Run the application
>
>
>
> The code is given below:
>
> /*
>
> * Click 
> nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt 
> to change this license
>
> * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java 
> to edit this template
>
> */
>
> package com.mycompany.menugui;
>
>
> /**
>
> *
>
> * @author zulfi
>
> */
>
> public class MenuGuiForm extends javax.swing.JFrame {
>
>
> /**
>
> * Creates new form MenuGuiForm
>
> */
>
> public MenuGuiForm() {
>
> initComponents();
>
> }
>
>
> /**
>
> * This method is called from within the constructor to initialize the 
> form.
>
> * WARNING: Do NOT modify this code. The content of this method is always
>
> * regenerated by the Form Editor.
>
> */
>
> @SuppressWarnings("unchecked")
>
> // <editor-fold defaultstate="collapsed" desc="Generated Code">
>
> private void initComponents() {
>
>
> jMenuItem1 = new javax.swing.JMenuItem();
>
> jMenuBar1 = new javax.swing.JMenuBar();
>
> jMenu1 = new javax.swing.JMenu();
>
> jMenu3 = new javax.swing.JMenu();
>
> jMenu2 = new javax.swing.JMenu();
>
>
> jMenuItem1.setText("jMenuItem1");
>
>
> setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
>
>
> jMenu1.setText("File");
>
>
> jMenu3.setText("jMenu3");
>
> jMenu1.add(jMenu3);
>
>
> jMenuBar1.add(jMenu1);
>
>
> jMenu2.setText("Edit");
>
> jMenuBar1.add(jMenu2);
>
>
> setJMenuBar(jMenuBar1);
>
>
> javax.swing.GroupLayout layout = new 
> javax.swing.GroupLayout(getContentPane());
>
> getContentPane().setLayout(layout);
>
> layout.setHorizontalGroup(
>
> layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
>
> .addGap(0, 400, Short.MAX_VALUE)
>
> );
>
> layout.setVerticalGroup(
>
> layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
>
> .addGap(0, 275, Short.MAX_VALUE)
>
> );
>
>
> pack();
>
> }// </editor-fold>
>
>
> /**
>
> * @param args the command line arguments
>
> */
>
> public static void main(String args[]) {
>
> /* Set the Nimbus look and feel */
>
> //<editor-fold defaultstate="collapsed" desc=" Look and feel setting 
> code (optional) ">
>
> /* If Nimbus (introduced in Java SE 6) is not available, stay with the 
> default look and feel.
>
> * For details see 
> http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
>
> */
>
> 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(MenuGuiForm.class.getName()).log(java.util.logging.Level.SEVERE,null, 
> ex);
>
> } catch (InstantiationException ex) {
>
> java.util.logging.Logger.getLogger(MenuGuiForm.class.getName()).log(java.util.logging.Level.SEVERE,null, 
> ex);
>
> } catch (IllegalAccessException ex) {
>
> java.util.logging.Logger.getLogger(MenuGuiForm.class.getName()).log(java.util.logging.Level.SEVERE,null, 
> ex);
>
> } catch (javax.swing.UnsupportedLookAndFeelException ex) {
>
> java.util.logging.Logger.getLogger(MenuGuiForm.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 MenuGuiForm().setVisible(true);
>
> }
>
> });
>
> }
>
>
> // Variables declaration - do not modify
>
> private javax.swing.JMenu jMenu1;
>
> private javax.swing.JMenu jMenu2;
>
> private javax.swing.JMenu jMenu3;
>
> private javax.swing.JMenuBar jMenuBar1;
>
> private javax.swing.JMenuItem jMenuItem1;
>
> // End of variables declaration
>
> }
>
> Zulfi.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: users-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists