Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2005

Tip: Looking for answers? Try searching our database.

Setting insets for a contentPane?

Thread view: 
Scott Steiner - 19 Jul 2005 16:55 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.