0

Not sure if I'm just using a visual basic approach, but I was under the impression i could use the window builder in eclipse to create my Jframes, then simply invoke them when the button/actionlistener is selected...

Like:

JButton btn_register = new JButton("Register");
        btn_register.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                frm_register.setvisible(true);

            }

frm_register is the class name for the register form...

2 Answers2

1
YourFrame frame=new YourFrame();
frame.setVisible(true);
Nicola Bena
  • 98
  • 1
  • 1
  • 10
1

frm_register is the class name for the register form...

I hope not. Class names should start with upper case character. For example: RegistrationForm.

Then you need code like:

RegistrationForm  register = new RegistrationForm();
register.setVisible( true );

This of course assumes that the constructor for the RegistrationForm adds components to the form and does a pack on the form.

i could use the window builder in eclipse to create my Jframes,

Also, you should not be using a JFrame. An application generally has a single JFrame. A child window would typically be a JDialog. See: The Use of Multiple JFrames: Good or Bad Practice?

Community
  • 1
  • 1
camickr
  • 321,443
  • 19
  • 166
  • 288