简体   繁体   中英

Opening a new GUI window on a main GUI using GUI builder on netbeans

I am playing about with GUI builder and i was wondering if there is an easy way to open the register window through the current main window (in reference to the page below). I am trying to do this through the menu bar.

I've been trying all day, because GUI Builder generates some code, its not possible to edit this code.

在此处输入图片说明

Thanks For the help!

Create a separate class which extends JDialog class and add your GUI components:

public Register extends JDialog {
   //Make GUI
   setModalityType(ModalityType.APPLICATION_MODAL); //Make it modal
}

Add ActionListener to that menu item which is supposed to open a register window:

mnuItmRegisteration.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
        Register r = new Register();
        r.setVisible(true);
    }
});

Right click on that shortcut button, click Events, click ActionPreformed.
There you should write codes to make your register window appear.
An example:

  private void RegisterationEventActionPerformed(java.awt.event.ActionEvent evt) { 
    JFrame Register = new Register();
    Register.setVisible(true);
  }

Remember to make another JFrame called ("Register" assuming u are using the code i gave) at the same package as your current JFrame Maybe u would probably should use the run button (The button with a Green Triangle or Arrow), run it try to press the menu item, it should appear the register window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM