Try this sample code:
import java.awt.*; import javax.swing.*; public class InsetTesting extends JFrame { private void createAndDisplayGUI() { setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setLocationByPlatform(true); JPanel contentPane = new JPanel(); contentPane.setOpaque(true); contentPane.setBorder(BorderFactory.createLineBorder( Color.DARK_GRAY.darker(), 5, true)); contentPane.setBackground(Color.WHITE); add(contentPane, BorderLayout.CENTER); pack(); setVisible(true); } public Insets getInsets() { return (new Insets(30, 20, 10, 20)); } public Dimension getPreferredSize() { return (new Dimension(200, 400)); } public static void main(String\u005B\u005D args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new InsetTesting().createAndDisplayGUI(); } }); } }
Here is the result of the same:

nIcE cOw
source share