Java tutorial
import java.awt.BorderLayout; import java.awt.Color; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextPane; import javax.swing.border.EmptyBorder; public class Main { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new TestPane()); frame.pack(); frame.setVisible(true); } } class TestPane extends JPanel { public TestPane() { setLayout(new BorderLayout()); setBorder(new EmptyBorder(10, 10, 10, 10)); JTextPane pane = new JTextPane(); JPanel panel = new JPanel(new BorderLayout()); JPanel innerPanel = new JPanel(new BorderLayout()); pane.setBorder(BorderFactory.createLineBorder(Color.BLACK)); innerPanel.add(pane); panel.add(innerPanel); add(panel); } }