Estou começando a aprender Layouts e o que me pareceu mais razoável foi o null, o problema é que quando eu executo o programa aparece a Janela em branco. No site da Oracle disse isso: You need to invoke revalidate and repaint after adding a component before it will show up in your container. Mas eu não entendi...
import java.awt.event.*;
import javax.swing.*;
public class Testenull {
public static void main(String[] args) {
JFrame janela = new JFrame("Janela");
janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
janela.setSize(600, 600);
janela.setResizable(true);
janela.setVisible(true);
JPanel painel = new JPanel();
JButton botao1;
painel.setLayout(null);
JLabel label = new JLabel("kleber");
label.setSize(100,100);
label.setLocation(10,10);
botao1 = new JButton("O.K.");
botao1.setLocation(100, 100);
botao1.setSize(300,300);
painel.add(botao1);
painel.add(label);
}
}