I have been trying to learn Buttons but it refuses to resize. Button1 (code below) just takes up the whole screen. I have seen other posts who's problem was that they didn't use
setMaximumSize();
but I'm using it and it still isn't working! I didn't make a JPanel yet. Here is my JFrame:
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Frame extends JFrame {
private JButton button1;
private JButton button2;
public Frame()
{
    button1 = new JButton("Hello button1");
    button2 = new JButton("Hello button2");
    button2.setMaximumSize(new Dimension(100,100));
    button1.setMaximumSize(new Dimension(100,100));
    add(button2);
    add(button1);
}
}
My main class is plain and simple:
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Panel extends JPanel{
public static void main(String args [])
 {
    Frame frame = new Frame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(500, 500);
    frame.setVisible(true);
  }
 }
 
     
    