Q:

I am making a calculator with swing but the buttons are all messed up

when I'm making my swing calculator and setting up the buttons, each button is evenly spaced but the last button to be add is always taking up the whole screen, here is the method for setting up the buttons;
private void setupRelations() {
    window.setJMenuBar(menuBar);
    window.setLayout(new BorderLayout());
    window.add(inputPanel, BorderLayout.NORTH);
    window.add(buttonsPanel);

    exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    copyResult.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            StringSelection selection = new StringSelection(input.getText());
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            clipboard.setContents(selection, null);
        }
    });
    pasteInput.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String result = "";
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            Transferable contents = clipboard.getContents(null);
            boolean hasTransferableText = (contents != null) &&
                    contents.isDataFlavorSupported(DataFlavor.stringFlavor);
            if (hasTransferableText) {
                try {
                    result = (String)contents.getTransferData(DataFlavor.stringFlavor);
                } catch (UnsupportedFlavorException ex){
                    System.out.println(ex);
                    ex.printStackTrace();
                } catch (IOException ex) {
                    System.out.println(ex);
                    ex.printStackTrace();
                }
            }
            input.setText(result);
        }
    });
    windowOperations.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

        }
    });
    specialOperations.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

        }
    });

    file.add(copyResult);
    file.add(pasteInput);
    file.add(exit);

    windows.add(windowOperations);
    windows.add(specialOperations);

    menuBar.add(file);
    menuBar.add(windows);

    inputPanel.setLayout(new BorderLayout());

    input.setEditable(false);
    input.setText("sss");
    input.setHorizontalAlignment(JTextField.CENTER);
    input.setFont(font);

    inputPanel.add(input);

    buttonsPanel.setLayout(new BorderLayout());
    buttonsPanel.setBounds(window.getX() + (75 - 65), window.getY() + 13, 500, 500);
    int sLength = 65;
    int padding = 75;

    for(int i = 0; i < buttonNames[i].length; i++) {
        for(int j = 0; j < buttonNames.length; j++) {
            JButton button = new JButton(buttonNames[j][i]);
            button.setBounds(buttonsPanel.getX() + i * padding,
                    buttonsPanel.getY() + j * padding, sLength, sLength);
            button.addActionListener(getActionListener(i, j));
            buttonsPanel.add(button);
        }
    }
}

The getActionListener method is only for getting the corrosponding action for the button, can someone help me?

A:

You have the wrong layout. In a BorderLayout, when you add a component without specifying north, south, east, or west, adds the component to the middle, and the component takes up all the space there.
Usually for a calculator, you want a GridLayout: it divides its available space into equal-size areas in rows and columns, usually exactly what you want for the numbers in a calculator.
To put those into a BorderLayout (on the assumption that you want other things on one side or the other of your number buttons), set the GridLayout on a panel, put the buttons into it, then put that panel into the (middle of the) (component with the) BorderLayout.

