Now I will setup two objects in java swing frame work.
One object named “PanelUser”, and one more object named “FrameRegister”.

PanelUser:

class PanelUser extends JPanel{

public JPanel getPanelUser(){

return this;

}

public void setPanelUser(JPanel passedPanel){

this = passedPanel

}

}

So now I want to access to PanelUser to get JPanel to user in my FrameRegister.

FrameRegister:

class FrameRegister extends JFrame{

PanelUser panelUser = new PanelUser();

public  FrameRegister(){

JPanel panel = panelUser.getPanelUser();

this.getContentPane().add(panel);

}

public static void main(String arg){

new FrameRegister().show();

}

}
Advertisements