DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009

    Layout Manager, Single component

    Hello all, I am new to this community and fair new to Java programming. I am reading about layout managers and used several layout managers in order to show a single component in a JPanel, eg a button. So far all i have found/managed to do is to make this button appear in a specific position leaving the rest of the space unoccupied.

    What I want to do is to show this button in the panel but occupy all available space as well as be resizable to the panel. Panel gets bigger? Button still occupies full size of it.

    Any help is appreciated, thank you.

  2. #2
    Join Date
    Mar 2004
    use border layout and put your component in the center.


    Code inside the init method of an applet, jframe or something else:

    setLayout(new BorderLayout());
    add(new Button("Center"), BorderLayout.CENTER);

    There is no fear in the true love!

Similar Threads

  1. Replies: 2
    Last Post: 05-05-2008, 08:54 PM
  2. Replies: 0
    Last Post: 01-17-2007, 10:38 PM
  3. How long before the next version??
    By _CAG in forum .NET
    Replies: 146
    Last Post: 08-12-2002, 10:40 PM
  4. Re: App Object (fixes)
    By Rob Teixeira in forum .NET
    Replies: 129
    Last Post: 06-06-2002, 05:23 AM
  5. Component Manager MSI file Client Installation
    By Jim Ferguson in forum Enterprise
    Replies: 3
    Last Post: 06-27-2000, 09:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.