1

I have a JDesktopPane where I add and show a JInternalFrame called ListarEmpleado.java. From that ListarEmpleado.java I open another JInternalFrame called InformacionEmpleado.java doing click in a button. I have a equation to locate InformacionEmpleado.java in the middle of the JDesktopPane when it is opened.

This is the button event (I code in Netbeans):

private void masInformacionActionPerformed(java.awt.event.ActionEvent evt) {                                               
    InformacionEmpleado verDetalle = new InformacionEmpleado(this.cedulaSeleccionada);
    escritorio = getDesktopPane();
    escritorio.add(verDetalle);

    int width = verDetalle.getParent().getWidth();
    int width1 = verDetalle.getWidth();
    int height = verDetalle.getParent().getHeight();
    int height1 = verDetalle.getHeight();

    verDetalle.setLocation(width / 2 - width1 / 2, height / 2 -  height1/ 2 - 10);
    verDetalle.setVisible(true);
}

The problem is when the line verDetalle.setVisible(true); is executed, InformacionEmpleado.java is located in the middle perfectly and I don't have problems with it, but if I have ListarEmpleado.java maximized, it returns to its initial size (does not stay maximized). Why does this happen and how can I fix it?

Thanks a lot!

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Cristiam Mercado
  • 573
  • 12
  • 34

0 Answers0