How can I set the insets on a JPanel?

I can see a method .getInsets for a JPanel but no method for setting the Insets. Any idea how I do this ?
[112 byte] By [richard_a_wright] at [2007-9-30 21:22:03]
# 1

well... you don't, really. You could subclass JPanel and override getInsets(), but typically, if you want to change the insets, it's common to use an empty border...

panel.setBorder(BorderFactory.createEmptyBorder(2, 3, 4, 5)); // top, left, bottom, right

or you can use that with a compound border if you need padding and some other border.

bsampieri at 2007-7-7 2:54:12 > top of Java-index,Desktop,Core GUI APIs...
# 2

JPanel jPanel = new JPanel() {

public Insets getInsets() {

return new Insets(4, 5, 4, 3);

}

};

hballenchen at 2007-7-7 2:54:12 > top of Java-index,Desktop,Core GUI APIs...