I am starting to program in Java and I have encountered this problem, I am using Eclipse
, the thing is that at the time of executing the program the JFrame
container of the others JPanel
is not displayed, and no I see the error
public class AddClient extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
//ATTR'S
private JFrame Frame;
private JPanel RPanel, LPanel, UPanel, CPanel;
private JButton LButton1, LButton2, LButton3;
private JButton RButton1, RButton2, RButton3;
private JButton UButton1, UButton2, UButton3;
private JButton CButton1, CButton2, CButton3;
private Container Cont;
//Constructor
public AddClient()
{
this.CPanel = null;
this.Frame = null;
this.RPanel = null;
this.LPanel = null;
this.UPanel = null;
this.CPanel = null;
this.RButton1 = null;
this.RButton2 = null;
this.RButton3 = null;
this.LButton1 = null;
this.LButton2 = null;
this.LButton3 = null;
this.UButton1 = null;
this.UButton2 = null;
this.UButton3 = null;
this.CButton1 = null;
this.CButton2 = null;
this.CButton3 = null;
this.Cont = null;
makeLPanel();
makeRPanel();
makeUPanel();
makeCPanel();
makeWindow();
}
// funcion para hacer el panes izquierdo
public void makeLPanel()
{
this.LPanel = new JPanel();
this.LButton1 = new JButton("LBoton1");
this.LButton2 = new JButton("LBoton2");
this.LButton3 = new JButton("LBoton3");
this.LPanel.setLayout(new BoxLayout(LPanel, BoxLayout.Y_AXIS));
this.LPanel.add(this.LButton1);
this.LPanel.add(this.LButton2);
this.LPanel.add(this.LButton3);
}
// funcion para hacer el panel Derecho
public void makeRPanel()
{
this.RPanel = new JPanel();
this.RButton1 = new JButton("RBoton1");
this.RButton2 = new JButton("RBoton2");
this.RButton3 = new JButton("RBoton3");
this.RPanel.setLayout(new BoxLayout(RPanel, BoxLayout.Y_AXIS));
this.RPanel.add(this.RButton1);
this.RPanel.add(this.RButton2);
this.RPanel.add(this.RButton3);
}
// FUNCION creacion de Panel Superior
public void makeUPanel()
{
this.UPanel = new JPanel();
this.UButton1 = new JButton("UBoton1");
this.UButton2 = new JButton("UBoton2");
this.UButton3 = new JButton("UBoton3");
this.UPanel.setLayout(new FlowLayout());
this.UPanel.add(this.UButton1);
this.UPanel.add(this.UButton2);
this.UPanel.add(this.UButton3);
}
//Panel Central
public void makeCPanel()
{
this.CPanel = new JPanel();
this.CButton1 = new JButton("LBoton1");
this.CButton2 = new JButton("LBoton2");
this.CButton3 = new JButton("LBoton3");
this.CPanel.setLayout(new BoxLayout(CPanel, BoxLayout.Y_AXIS));
this.CPanel.add(this.CButton1);
this.CPanel.add(this.CButton2);
this.CPanel.add(this.CButton3);
}
//Creamos Ventana principal
public void makeWindow()
{
this.Frame = new JFrame();
this.Frame.setTitle("Gestion de Bienes Raices");
this.Frame.setSize(1000, 900);
this.Frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.Frame.setLocationRelativeTo(null);
this.Frame.setResizable(false);
Cont = Frame.getContentPane();
Cont.setLayout(new BorderLayout());
Cont.add(this.UPanel, BorderLayout.NORTH);
Cont.add(this.CPanel, BorderLayout.CENTER);
Cont.add(this.RPanel, BorderLayout.EAST);
Cont.add(this.LPanel, BorderLayout.WEST);
}
/* esto va en la clase main de nombre
RealState y pretendo llamar la clase addClient
desde acá y cargar el JFrame. */
public class RealState {
public static void main(String[] args) {
// Inicializamos
AddClient pf = new AddClient();
pf.setVisible(true);
}
}
}