O exercício consiste em exibir o seguinte resultado em anexo
mas está todo desalinhado o meu projeto. tá aí o código bagunçado
import javax.swing.JButton;
import javax.swing.JFrame;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.JTextArea;
public class Alinhamento extends JFrame{
private JTextArea areaX;
private JTextArea areaY;
private JPanel esquerda;
private JPanel centro;
private JPanel direita;
private JButton ok;
private JButton Cancelar;
private JButton ajuda;
private JCheckBox ajustarGrade;
private JCheckBox mostrarGrade;
private JLabel x;
private JLabel y;
public Alinhamento(){
super("Alinhamento");
//setLayout(new BorderLayout());
esquerda = new JPanel(new GridLayout(2,1));
ajustarGrade = new JCheckBox("Ajustar Grade");
mostrarGrade = new JCheckBox("Mostrar Grade");
esquerda.add(ajustarGrade);
esquerda.add(mostrarGrade);
add(esquerda, BorderLayout.WEST);
centro = new JPanel(new GridLayout(2,2));
x = new JLabel("X:");
centro.add(x);
areaX = new JTextArea(1,5);
centro.add(areaX);
y = new JLabel("Y:");
centro.add(y);
areaY = new JTextArea(1,5);
centro.add(areaY);
add(centro, BorderLayout.CENTER);
direita = new JPanel(new GridLayout(3,1,5,5));
ok = new JButton("OK");
//ok.setVerticalAlignment(50);
Cancelar = new JButton("Cancelar");
ajuda = new JButton("Ajuda");
direita.add(ok);
direita.add(Cancelar);
direita.add(ajuda);
add(direita, BorderLayout.EAST);
}
}