How to add a JButton into the center of a JFrame with BorderLayout()? I tried using BorderLayout.CENTER, but instead of the center
BorderLayout()
BorderLayout.CENTER
try this
frame.getContentPane().setLayout(new BorderLayout(0, 0)); JButton btnNewButton = new JButton("New button"); frame.getContentPane().add(btnNewButton, BorderLayout.CENTER);