Java tutorial
import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; public class Main { public static void main(String[] args) { int specificX = 40; int specificY = 20; JPanel gui = new JPanel(new BorderLayout()); JTextField tf = new JTextField(10); JPanel borderPanel = new JPanel(new GridLayout()); borderPanel.add(tf); borderPanel.setBorder(new EmptyBorder(specificX, specificY, specificX, specificY)); borderPanel.setBackground(Color.GREEN); gui.add(borderPanel); JOptionPane.showMessageDialog(null, gui); } }