I have a detail in my application, I have a menu in which is called a JInternalFrame, and something curious happens, when I call it the first time it appears, when I close it with the dispose () function, but ... when I repeat this operation, the third time it generates an exception that says:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: illegal component position
The block of code that I do the previous procedure is the following:
mntmSesion = new JMenuItem("Sesion");
mntmSesion.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(mntmSesion.getText().equals("Cerrar Sesion")) {
System.out.println("Cerrando sesion");
operDB.eliminarTabla("sesionActiva");
p2.dispose();
p3.dispose();
p4.dispose();
p5.dispose();
p6.dispose();
p7.dispose();
pgarrafon.dispose();
}else {
desktopPane.add(p1);
p1.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
p1.show();
}
}
});
mnInicio.add(mntmSesion);
After the exception, if I click, if I show the JInternalFrame