Java, configurando o layout como nulo
Eu tenho usado um layout nulo e muitas pessoas dirão que não deve ser feito dessa maneira. Existe uma maneira melhor?
Algum código como exemplo:
import javax.swing.*;
public class Main{
public static void main(String args[]){
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton button = new JButton("Click");
//JFrame, frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setSize(500, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
//JPanel, panel
panel.setLayout(null); //<<---- Is this correct?
frame.add(panel);
//JButton, button
button.setBounds(25, 25, 100, 60); //<<---- Is this correct?
panel.add(button);
}
}