So I am trying to make a panel that stretches across my entire programs with, and has about 20 pixels worth of height. For some reason there is only a small box that is the panel. Can anybody tell me why it isn't stretching to the entire width? I'm fairly new to Java, so sorry if the code is a little messy/wrong.
GridPane Class
public GridPane() {
gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.NORTH;
gbc.weighty = 1.0;
horizontalGrid = new JButton();
horizontalGrid.setText("Horizontal Grid");
options = new JPanel(new BorderLayout());
options.setBackground(Color.black);
options.add(horizontalGrid);
add(options, gbc);
}
Game Class
public class Game extends JPanel implements ActionListener{
//DECLARATIONS
private static final long serialVersionUID = 1L;
public GridPane grid = new GridPane();
//DECLARATIONS END
//CONSTRUCTOR
public Game() {
this.add(grid);
}
//CONSTRUCTOR ENDS
//MAIN METHOD
public static void main(String[] args) {
JFrame frame = new JFrame();
Game game = new Game();
frame.setResizable(true);
frame.setAlwaysOnTop(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(game);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
//MAIN METHOD ENDS
//ACTION METHOD
public void actionPerformed(ActionEvent e) {
}