Dimensions of BorderLayout zones

0

I have a problem in the interface that I am developing. I have 4 panels (Oest, Center, East and South) inside another panel, the problem is that I want to modify the size of the center panel since it is too big and this decreases the size of the right panel. How do I do it?

Central panel code (constructor):

public InformationStudentLabel ()     {

    TitledBorder borde = (new TitledBorder("Centro"));
    setBorder(borde);



    setLayout (new GridLayout (7,1));


    codigo = new JLabel ("Código:");
    nombres = new JLabel ("Nombres:");
    apellidos = new JLabel ("Apellidos:");
    semestreIngreso= new JLabel ("Semestre de ingreso:");
    facultad = new JLabel ("Facultad:");
    promedio = new JLabel ("Promedio:");
    intercambio = new JLabel ("Intercambio:");



    add(codigo);
    add(nombres);
    add(apellidos);
    add(semestreIngreso);
    add(facultad);
    add(promedio);
    add(intercambio);
}

right panel code (constructor):

public Student Information ()     {

    TitledBorder borde = (new TitledBorder("Derecha"));
    setBorder(borde);

    setLayout (new GridLayout (8,1));

    codigoT = new JTextField ("");
    codigoT.setEditable(false);


    nombresT = new JTextField ("");
    nombresT.setEditable(false);

    apellidosT = new JTextField ("");
    apellidosT.setEditable(false);

    semestreIngresoT = new JTextField ("");
    semestreIngresoT.setEditable(false);

    facultadT = new JTextField ("");
    facultadT.setEditable(false);

    promedioT = new JTextField ("");
    promedioT.setEditable(false);

    intercambioT = new JCheckBox ();


    cambiarPromedio = new JButton ("Cambiar Promedio");



    add(codigoT);

    add(nombresT);

    add(apellidosT);

    add(semestreIngresoT);

    add(facultadT);

    add(promedioT);

    add(intercambioT);


    add(cambiarPromedio);

}

Code of the panel that inherits the previous 2 (constructor):

Public Body ()     {

    setLayout(new BorderLayout ());




    TitledBorder borde = BorderFactory.createTitledBorder("Información estudiante");
    borde.setTitleColor(Color.black);
    setBorder(borde);

    imagen = new ImgEstudiante ();
    add (imagen, BorderLayout.WEST);

    informacionEstudianteLabel = new InformacionEstudianteLabel();
    add(informacionEstudianteLabel, BorderLayout.CENTER);

    informacionEstudiante = new InformacionEstudiante ();
    add (informacionEstudiante, BorderLayout.EAST);




    navegacion = new Navegacion();
    add(navegacion, BorderLayout.SOUTH);





}
    
asked by Joaquin Sebastian 21.05.2017 в 03:01
source

1 answer

0

The BorderLayout is thinking so that the central panel occupies the maximum possible, respecting the size that the panels of the edges need.

If you want the panel on the right to become wider, the panel on the right has to "say" in some way that wants to occupy more width than it really needs.

In the Student Information class (I think it's the panel on the right), overwrite the getPreferredSize () and / or getMinimumSize () method to return the width you need.

Greetings.

    
answered by 21.05.2017 / 06:59
source