Java tutorial
import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog; public class Main extends JDialog implements ActionListener { private javax.swing.JButton testButton; public Main() { setPreferredSize(new Dimension(640, 480)); getContentPane().setLayout(new BorderLayout()); testButton = new JButton("Click me"); testButton.addActionListener(this); getContentPane().add(testButton, BorderLayout.SOUTH); pack(); } @Override public void actionPerformed(ActionEvent e) { Insets insets = this.getInsets(); System.out.println(insets.top); System.out.println(insets.left); } public static void main(String args[]) { new Main().setVisible(true); } }