When I add buttons to a panel, the buttons seem to take a huge amount of space. How do I get rid of the space? For example:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Tester
{
public static void main(String[] args)
{
JButton dayButton = new JButton("Day");
JButton weekButton = new JButton("Week");
JButton monthButton = new JButton("Month");
JButton leftButton = new JButton("<<");
JButton rightButton = new JButton(">>");
JPanel topButtonPanel = new JPanel();
topButtonPanel.add(dayButton);
topButtonPanel.add(weekButton);
topButtonPanel.add(monthButton);
JPanel bottomButtonPanel = new JPanel();
bottomButtonPanel.add(leftButton);
bottomButtonPanel.add(rightButton);
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));
buttonPanel.add(topButtonPanel);
buttonPanel.add(bottomButtonPanel);
JFrame frame = new JFrame();
frame.add(buttonPanel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
frame.setVisible(true);
}
private static final int FRAME_WIDTH = 1000;
private static final int FRAME_HEIGHT = 1000;
}