Para la disposicion de los paneles he utilizado gridbagLayout, ya que no todos los paneles tienen el mismo tamaño, he utilizado la constante weightx para poner los tamaños pero al final acaba cogiendo a todos con el mismo tamaño, os dejo el codigo.
Código:
Si no encontrais el error, me podriais decir algun manual decente donde lo expliquen, sobre todo los parametros weightx y weighty que es donde creo que esta el fallo.jPanel1 = new JPanel(); jPanel2 = new JPanel(); jPanel3 = new JPanel(); jPanel4 = new JPanel(); jPanel5 = new JPanel(); jPanel6 = new JPanel(); jPanel7 = new JPanel(); this.getContentPane().setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); //Ahora a cada panel le asociamos una disposicion en la ventana principal //Panel 1: tickets constraints.gridx=0; constraints.gridy=0; constraints.gridheight=1; constraints.gridwidth=2; constraints.weighty= 1.0; constraints.weightx=1.0; constraints.fill=constraints.BOTH; constraints.anchor=constraints.NORTHWEST; this.getContentPane().add(jPanel1, constraints); jPanel1.setBackground(Color.RED); //Panel 4: Calculadora constraints.gridx=2; constraints.gridy=0; constraints.gridheight=1; constraints.gridwidth=1; constraints.weighty = 1.0; // constraints.weightx= 1.0; constraints.fill=constraints.BOTH; this.getContentPane().add(jPanel4, constraints); jPanel4.setBackground(Color.CYAN); //Panel 2: Familias constraints.gridx=0; constraints.gridy=1; constraints.gridheight=1; constraints.gridwidth=1; constraints.weighty = 1.0; // constraints.weightx= 1.0; constraints.fill=constraints.BOTH; this.getContentPane().add(jPanel2, constraints); jPanel2.setBackground(Color.YELLOW); //Panel 3: Productos constraints.gridx=1; constraints.gridy=1; constraints.gridheight=1; constraints.gridwidth=2; constraints.weighty = 1.0; constraints.weightx=1.0; constraints.fill=constraints.BOTH; this.getContentPane().add(jPanel3, constraints); jPanel3.setBackground(Color.BLUE); //Panel 5: Botones constraints.gridx=3; constraints.gridy=0; constraints.gridheight=3; constraints.gridwidth=1; constraints.weighty = 1.0; constraints.weightx=0.4; constraints.fill=constraints.BOTH; this.getContentPane().add(jPanel5, constraints); jPanel5.setBackground(Color.BLACK); //Panel 6: Mesa y Barra constraints.gridx=0; constraints.gridy=2; constraints.gridheight=1; constraints.gridwidth=1; constraints.weighty = 0.2; constraints.weightx= 0.0; constraints.fill=constraints.BOTH; this.getContentPane().add(jPanel6, constraints); jPanel6.setBackground(Color.GRAY); //Panel 7:Camareros constraints.gridx=1; constraints.gridy=2; constraints.gridheight=1; constraints.gridwidth=2; constraints.weighty = 0.2; constraints.weightx=1.0; constraints.fill=constraints.BOTH; this.getContentPane().add(jPanel7, constraints); jPanel7.setBackground(Color.WHITE);
Muchas Gracias.