Java JFrame content pane with null layout manager
import java.awt.Container; import javax.swing.JButton; import javax.swing.JFrame; public class Main { public static void main(String[] args) { JFrame frame = new JFrame("Adding Components to JFrame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); // Add a Close button //ww w .j a v a 2s .c o m contentPane.setLayout(null); JButton closeButton = new JButton("Close"); contentPane.add(closeButton); closeButton.setBounds(10, 10, 30, 30); frame.setSize(200,200); frame.setVisible(true); } }