Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Setting insets for a contentPane?

Reply
Thread Tools

Setting insets for a contentPane?

 
 
Scott Steiner
Guest
Posts: n/a
 
      07-19-2005
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!
 
Reply With Quote
 
 
 
 
Thomas Hawtin
Guest
Posts: n/a
 
      07-19-2005
Scott Steiner wrote:
>
> 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
--
Unemployed English Java programmer
 
Reply With Quote
 
 
 
 
Vova Reznik
Guest
Posts: n/a
 
      07-19-2005
Scott Steiner wrote:
> 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!


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
python-dev and setting up setting up f2py on Windows XP Sile Python 5 08-18-2006 08:13 AM
How to set JTabbedPane content insets? Allen Java 0 08-14-2006 08:47 AM
tomcat 4.x : setting mime type for a directory or setting a default mime type CJ Java 1 10-29-2004 07:51 PM
Setting a configurable time-out setting for all the communication initiated with Remoting object. Srinivasa Raghavan Sethuraman ASP .Net 0 06-30-2004 10:05 AM
JButton Insets Ike Java 0 08-29-2003 07:05 PM



Advertisments