0
Which Layout manager should I use to position the panels as in the illustrative image below.
Edit: I have the Painelx Class, which I am in JFrame
as position SOUTH
, within that class I have 2 panels (Panel 02 and 03), I want to orient one panel to the left and the other to the right.
I tried to apply the BorderLayout
to position the secondary panels (panel 2 and 3), but it did not work.
Example of what I did:
package tool;
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Teste extends JFrame
{
public static void main(String[] args) {
Teste teste = new Teste();
teste.setVisible(true);
}
private PainelX painel = new PainelX();
public Teste()
{
setSize(600, 400);
getContentPane().add("South", painel);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
class PainelX extends JPanel
{
public PainelX()
{
setBackground(Color.red);
add(painel02(), BorderLayout.EAST);
add(painel03(), BorderLayout.WEST);
}
private JComponent painel02()
{
JPanel painel = new JPanel();
JLabel teste = new JLabel("Painel 02");
painel.add(teste);
return painel;
}
private JComponent painel03()
{
JPanel painel = new JPanel();
JLabel teste = new JLabel("Painel 03");
painel.add(teste);
return painel;
}
}
I don’t see pictures, so I couldn’t really understand what you want to do.
– user28595
@diegofm the image does not appear ?
– JavaTech
It is blocked for me. Why it is important to always explain verbatim, the image should be complementary and not "the" explanation.
– user28595
@diegofm edited the question, give a look if this understandable.
– JavaTech
Want to position the two panels side by side? Just that?
– user28595
@diegofm not literally, I want to leave one on the "star left and right", the way they are in the example, they are side by side, only that they are together, I wanted them to be separated. Between them there was a space, perhaps it would be necessary to have a half empty panel, to be able to give this space ?
– JavaTech