Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/01/2013, 15:41
Avatar de detective_jd
detective_jd
 
Fecha de Ingreso: abril-2011
Ubicación: Salto
Mensajes: 437
Antigüedad: 13 años
Puntos: 6
Adaptar largo y ancho de un jframe al de un jpanel

Hola, quiero saber como cambiar el largo y ancho del jframe al de un jpanel.
Veras quiero usar el patron factory para fabricar paneles asi:

package institutomymaster.vistas.util;
import javax.swing.JPanel;
public class FabricarAcciones
{
public JPanel fabricarPanelAcciones(String xaccion,String xtipo,Object obj)
{
if(xaccion.equals("Guardar") && xtipo.equals("Carrera") && obj==null)
return new AccionCarrera(xaccion,xtipo,null);
else
return null;
}
}

y del jframe:

public class frmAcciones extends javax.swing.JFrame
{
private String accion;
private String tipo;
private Object obj;
private JPanel objpanel;
public frmAcciones(String xaccion,String xtipo,Object xobj)
{
initComponents();
accion=xaccion;
tipo=xtipo;
obj=xobj;
this.setTitle(accion+" "+ tipo);
objpanel=FachadaVentanas.getInstance().fabricarPan elAcciones(accion, tipo, obj);
//this.pack();
this.mostrarPanel(objpanel);
}
private void mostrarPanel(JPanel xobjpanel)
{
this.superPanel.removeAll();
this.superPanel.add(xobjpanel);
this.superPanel.setLayout(new GridLayout());
this.setSize(xobjpanel.getWidth(),xobjpanel.getHei ght());
// this.setSize(491,137);
this.superPanel.updateUI();
}

y el largo y ancho no me genera y no se que hacer.

Espero una ayuda y una respuesta.