Uzyskaj rzeczywisty rozmiar zawartości JFrame

Dostaję JFrame i chcę wyświetlić JLabel z obramowaniem z dopełnieniem wynoszącym może 50px. Kiedy ustawię rozmiar JFrame na 750, 750 i rozmiar JLabel na 650, 650 i lokalizację na 50, 50, wyświetli to dziwne ... Oto mój kod:

public class GUI {

    /**
     * Declarate all 
     */
    public int height = 750;
    public int width = 750;

    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width / 2) - (width / 2); // Center horizontally.
    int y = (screen.height / 2) - (height / 2); // Center vertically.

    /**
     * Create the GUI
     */
    JFrame frame = new JFrame();
    Border border = LineBorder.createBlackLineBorder();
    JLabel label = new JLabel();    

    public GUI(){
        label.setBorder(border);
        label.setSize(700, 700);
        label.setLocation(0, 0);

        frame.getContentPane().setLayout(null);
        frame.add(label);
    }

    public void createGUI() {
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setBounds(x,y,width,height);
        frame.setVisible(true);
    }

}

Więc myślę, że pasek tytułu u góry jest również zawarty w rozmiarze. W grafice możesz użyćgetInsets(). Czy jest coś takiego dla Swing / JFrame?

questionAnswers(2)

yourAnswerToTheQuestion