Trip Therapy
Trip Therapy

Reputation: 317

Change JFrame in WindowBuilder Eclipse

I'm working with swing and I'm not able to change the JFrame in COMPONENTS area in WindowBuilder. I can only see the main frame. When I press a button I create a new Frame but I cant edit it with WindowBuilder.

enter image description here

        frameMain.setVisible(false);
        frameLogin = new JFrame("Login Admin");
        frameLogin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frameLogin.setSize(600, 400);
        frameLogin.setLocationRelativeTo(null);
        frameLogin.setVisible(true);

I WANT TO EDIT frameLogin in WindowBuilder, any solution? By creating a new JFrame in WindowBuilder it creates another class in other file. enter image description here

Upvotes: 0

Views: 2296

Answers (1)

Trip Therapy
Trip Therapy

Reputation: 317

I did this : In my view (frameMain) I declared this :

private loginFrameAdmin frameLoginA;
private loginFrameUser frameLoginU;

where loginFrameAdmin is a JFrame like this :

import javax.swing.JFrame;

public class loginFrameAdmin {

    private JFrame frameLogin;
    public loginFrameAdmin() {
        frameLogin = new JFrame("Login Amministratore");
        frameLogin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frameLogin.setSize(600, 400);
        frameLogin.setLocationRelativeTo(null);
        frameLogin.setVisible(true);
    }
}

Then in the same view (frameMain) I added a class :

public void adminPage() {
        JOptionPane.showMessageDialog(null, "Login for admins");
        frameMain.setVisible(false);
        frameLoginA = new loginFrameAdmin();
    }

And now I'm able to edit my JFrame, thanks to @kalsowerus

Upvotes: 1

Related Questions