Layout Manager, Single component


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Layout Manager, Single component

  1. #1
    Join Date
    Aug 2009
    Posts
    1

    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
    Posts
    78
    use border layout and put your component in the center.

    http://java.sun.com/javase/6/docs/ap...derLayout.html

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

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

    Bye
    There is no fear in the true love!

Similar Threads

  1. Replies: 2
    Last Post: 05-05-2008, 09:54 PM
  2. Replies: 0
    Last Post: 01-17-2007, 11:38 PM
  3. How long before the next version??
    By _CAG in forum .NET
    Replies: 146
    Last Post: 08-12-2002, 11:40 PM
  4. Re: App Object (fixes)
    By Rob Teixeira in forum .NET
    Replies: 129
    Last Post: 06-06-2002, 06:23 AM
  5. Component Manager MSI file Client Installation
    By Jim Ferguson in forum Enterprise
    Replies: 3
    Last Post: 06-27-2000, 10: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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

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