Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public DisplayMainMenu() throws HeadlessException {
- //add variables
- final JFrame frame = new JFrame("Checker (menu)");
- final int numberOfSquares = 10;
- final int buttonTextSize = 25;
- final Dimension preferredSize =
- new Dimension(BoardAndMouse.SQUARE_SIZE * numberOfSquares, BoardAndMouse.SQUARE_SIZE * numberOfSquares);
- //create start button, first button
- JPanel startGamePanel = new JPanel();
- startGamePanel.setLayout(null);
- frame.add(startGamePanel);
- JButton startGameButton = new JButton("Start new game");
- startGameButton.setFont(new Font("Times", Font.PLAIN, buttonTextSize));
- startGameButton.setBounds(200,200, 220, 75); //x,y and then width and height
- startGamePanel.add(startGameButton);
- //create quit button, second button
- JPanel quitGamePanel= new JPanel();
- quitGamePanel.setLayout(null);
- frame.add(quitGamePanel);
- JButton quitGameButton = new JButton("Quit");
- quitGameButton.setFont(new Font("Times", Font.PLAIN, buttonTextSize));
- quitGameButton.setBounds(200,300, 220, 75); //x,y and then widht and height
- quitGamePanel.add(quitGameButton);
- //manage frame
- frame.setPreferredSize(preferredSize);
- frame.setResizable(false);
- //frame.setContentPane(menu); //make use of paintComponent in MainMenu
- frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- frame.setLocationRelativeTo(null);
- frame.pack(); //size the frame so all its content are at or above their preferred sizes
- frame.setVisible(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement