Fix de layout

This commit is contained in:
roche 2019-11-16 17:29:15 +01:00
parent cc5f59b5aa
commit 8bfab6a9dc
2 changed files with 16 additions and 22 deletions

View File

@ -51,31 +51,34 @@ public class Menu extends JFrame{
this.cargarGestiones(LocalDate.now().getYear(), LocalDate.now().getMonth()); this.cargarGestiones(LocalDate.now().getYear(), LocalDate.now().getMonth());
this.cargarPestanias(); this.cargarPestanias();
this.setLayout(new GridBagLayout());
this.panel = new VistaPanelLateral(constrain, this.meses);
this.panelCentral = new JPanel(); this.panelCentral = new JPanel();
this.panelCentral.setLayout(new GridBagLayout());
this.panel = new VistaPanelLateral(this.meses);
constrain.fill = GridBagConstraints.HORIZONTAL; constrain.fill = GridBagConstraints.HORIZONTAL;
constrain.gridx = 0; constrain.gridx = 0;
constrain.gridwidth = 2;
constrain.gridy = 0; constrain.gridy = 0;
constrain.weightx = 10; constrain.weightx = 0;
this.add(this.barra); this.panelCentral.add(this.barra,constrain);
constrain.fill = GridBagConstraints.VERTICAL; constrain.fill = GridBagConstraints.HORIZONTAL;
constrain.gridx = 1; constrain.gridwidth = 1;
constrain.gridx = 0;
constrain.gridy = 1; constrain.gridy = 1;
constrain.weightx = 2; constrain.weightx = 0.25;
this.panelCentral.add(pestania,constrain); this.panelCentral.add(pestania,constrain);
getContentPane().add(pestania);
setTitle("Titulo"); setTitle("Titulo");
setSize(new Dimension(420,320)); setSize(new Dimension(420,320));
setDefaultCloseOperation(3); setDefaultCloseOperation(3);
setLocationRelativeTo(null); setLocationRelativeTo(null);
ControladorPanelLateral controlador3 = new ControladorPanelLateral(this.panel, this); ControladorPanelLateral controlador3 = new ControladorPanelLateral(this.panel, this);
this.listenerPestania(); this.listenerPestania();
constrain.fill = GridBagConstraints.VERTICAL; constrain.fill = GridBagConstraints.HORIZONTAL;
constrain.gridx = 2; constrain.gridx = 1;
constrain.gridy = 1; constrain.gridy = 1;
constrain.weightx = 2; constrain.weightx = 0.25;
this.add(this.panel); this.panelCentral.add(this.panel,constrain);
this.add(this.panelCentral);
} }
private void close(){ private void close(){

View File

@ -22,7 +22,7 @@ public class VistaPanelLateral extends JPanel{
JButton aniadirGestion; JButton aniadirGestion;
JButton eliminarTransaccion; JButton eliminarTransaccion;
Meses meses; Meses meses;
VistaPanelLateral(GridBagConstraints constrain, Meses meses){ VistaPanelLateral(Meses meses){
this.setPreferredSize(new Dimension(200,200)); this.setPreferredSize(new Dimension(200,200));
this.meses=meses; this.meses=meses;
this.total = new JTextArea(String.valueOf(meses.getTotal())); this.total = new JTextArea(String.valueOf(meses.getTotal()));
@ -30,17 +30,8 @@ public class VistaPanelLateral extends JPanel{
this.mostrarEstadisticas = new JButton("Mostrar grafico del mes"); this.mostrarEstadisticas = new JButton("Mostrar grafico del mes");
this.aniadirGestion = new JButton("Aniadir nueva gestión"); this.aniadirGestion = new JButton("Aniadir nueva gestión");
this.add(this.mostrarEstadisticas); this.add(this.mostrarEstadisticas);
constrain.gridx = 1;
constrain.gridy = 0;
constrain.weightx = 2;
this.add(VistaPanelLateral.elegirMes); this.add(VistaPanelLateral.elegirMes);
constrain.gridx = 1;
constrain.gridy = 1;
constrain.weightx = 2;
this.add(this.total); this.add(this.total);
constrain.gridx = 1;
constrain.gridy = 2;
constrain.weightx = 2;
this.add(this.gastoEnvio); this.add(this.gastoEnvio);
this.add(this.aniadirGestion); this.add(this.aniadirGestion);
this.eliminarTransaccion = new JButton("Eliminar Deseleccionados"); this.eliminarTransaccion = new JButton("Eliminar Deseleccionados");