Hi,
I want to add a JPanel that has a border to a JFrame. Here's what I did:
public class Test2 extends JFrame
{
...
public Test2()
{
...
Container con = this.getContentPane();
con.setLayout(new BorderLayout());
JPanel pane = new JPanel();
pane.setBorder(BorderFactory.createEtchedBorder());
con.add(pane);
...
}
}
All is fine but the border of the panel is far too close to the border
of the frame. Is there some way of setting insets for the contentpane? I
saw a getInsets() method for the frame and for the contentpane but I see
nothing that would allow me to set the insets.
Thanks!
Thomas Hawtin - 19 Jul 2005 16:56 GMT
> All is fine but the border of the panel is far too close to the border
> of the frame. Is there some way of setting insets for the contentpane? I
> saw a getInsets() method for the frame and for the contentpane but I see
> nothing that would allow me to set the insets.
I would suggest looking at javax.swing.border.CompoundBorder.
Tom Hawtin

Signature
Unemployed English Java programmer
Vova Reznik - 19 Jul 2005 17:16 GMT
> Hi,
>
[quoted text clipped - 23 lines]
>
> Thanks!
javax.swing.border.AbstractBorder
public Insets getBorderInsets(Component c)
You can create your own Border (extending any Border you like) and
override that method and set that border to content pane.
Content pane of JFrame (not only) has BorderLayout by default