I would do a Layouts composition, to fix the components in the footer would use the BorderLayout and would put a panel
in the position PAGE_END.
Thepanel
ofPAGE_ENDwouldalsobeoftheBorderLayouttype,soyoucansettheExitrightbutton(LINE_END),anditwouldhaveanotherpanel
toputthetwonavigationbuttons,thoseintheCENTERposition.Forthe%sof%softhebuttons,IwoulduseMigLayouttomakethemresponsive.
Thestructurelookslikethis:
The end result would look like this:
Code:
importjava.awt.BorderLayout;importjava.awt.EventQueue;importjavax.swing.JFrame;importjavax.swing.JPanel;importjavax.swing.border.EmptyBorder;importjavax.swing.JButton;importnet.miginfocom.swing.MigLayout;importjava.awt.Color;importjava.awt.Dimension;publicclassComposicaoDeLayoutsextendsJFrame{privatestaticfinallongserialVersionUID=1L;privateJPanelcontentPane;/***Launchtheapplication.*/publicstaticvoidmain(String[]args){EventQueue.invokeLater(newRunnable(){publicvoidrun(){try{ComposicaoDeLayoutsframe=newComposicaoDeLayouts();frame.setVisible(true);}catch(Exceptione){e.printStackTrace();}}});}/***Createtheframe.*/publicComposicaoDeLayouts(){setMinimumSize(newDimension(400,300));setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100,100,450,300);contentPane=newJPanel();contentPane.setBorder(newEmptyBorder(5,5,5,5));setContentPane(contentPane);contentPane.setLayout(newBorderLayout(0,0));JPanelpnlCenter=newJPanel();pnlCenter.setBackground(Color.WHITE);contentPane.add(pnlCenter,BorderLayout.CENTER);JPanelpnlSouth=newJPanel();contentPane.add(pnlSouth,BorderLayout.SOUTH);pnlSouth.setLayout(newBorderLayout(0,0));JPanelpnlBotoesNavegacao=newJPanel();pnlSouth.add(pnlBotoesNavegacao,BorderLayout.CENTER);pnlBotoesNavegacao.setLayout(newMigLayout("", "[1,grow 2][100px][100px][1,grow 1]", "[40px]"));
JButton btnAnterior = new JButton("<< Anterior");
pnlBotoesNavegacao.add(btnAnterior, "cell 1 0,grow");
JButton btnProximo = new JButton("Proximo >>");
pnlBotoesNavegacao.add(btnProximo, "cell 2 0,grow");
JPanel pnlBotaoSair = new JPanel();
pnlSouth.add(pnlBotaoSair, BorderLayout.EAST);
pnlBotaoSair.setLayout(new MigLayout("", "[100px]", "[40px]"));
JButton btnSair = new JButton("Sair");
pnlBotaoSair.add(btnSair, "cell 0 0,grow");
}
}