This Java Swing tip illustrates a method of interacting directly with the JRootPane of a JFrame. JRootPane is a lightweight container used behind the scenes by JFrame, JDialog, JWindow, JApplet, and JInternalFrame.

 import java.awt.*;
import javax.swing.*;

public class RootExample {
    
    public static void main(String[] args) {
        
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        JRootPane root = f.getRootPane();
        Container content = root.getContentPane();
        content.add(new JButton("Hello"));
        
        f.pack();
        f.setVisible(true);
        
    }
}