И это всё МОЁ
JFrame frame = new JFrame();
frame.setLocation(0, 0);
frame.setSize(300,300);
JButton button = new JButton("close";);
button.setSize(100,50);
//Dimension dim = new Dimension();
//dim.width = 100;
//dim.height = 50;
//button.setMaximumSize(dim);
button.setBounds(100, 150, 100, 50);
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e)
{
frame.dispose();
}
});
JPanel panel = new JPanel();
panel.setSize(frame.getSize());
panel.add(button);
//button.setLocation(100, 250);
frame.add(panel);


https://ibb.co/5hP4VP5