Results 1 to 5 of 5
  1. #1
    justbeller is offline Member
    Join Date
    Dec 2010
    Posts
    57
    Rep Power
    0

    Post How to set Jpanel in the center of frame when Increase the size of frame

    Hello Every One

    I have problem in java program how can I get jpanel in the center of Jframe when I increase the size of frame jpanel is not in center please solve my problem

    waiting

    Yougeshwar Khatri

  2. #2
    hosscomp is offline Member
    Join Date
    Oct 2010
    Posts
    63
    Rep Power
    0

    Default

    You have to use the right layout manager.

  3. #3
    miller.bartek is offline Member
    Join Date
    Jan 2011
    Posts
    8
    Rep Power
    0

    Default

    As hosscomp said, you have to use appropriate layout.
    There are many solutions, but I will suggest you one of them.

    You can use FlowLayout.CENTER

    Whenever you create a JPanel using No-Argument Constructor
    JPanel p = new JPanel();
    it uses by default FlowLayout.CENTER .

    Adding any component to this panel will center it, and while resizing it will also stay in the middle.

    Look:

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default

    Set a GridBagLayout and add the inner panel without a constraint.

    db

  5. #5
    justbeller is offline Member
    Join Date
    Dec 2010
    Posts
    57
    Rep Power
    0

    Default

    thanks every one for help its working
    GridBagLayout
    & also working FlowLayout

Similar Threads

  1. Java slave Frame access to its owner main frame problem
    By cagdaseckin in forum New To Java
    Replies: 0
    Last Post: 12-10-2010, 10:40 AM
  2. Replies: 4
    Last Post: 11-12-2010, 04:25 AM
  3. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 04:37 PM
  4. Prob. with screen resolution and Frame size??
    By SANDY_INDIA in forum AWT / Swing
    Replies: 1
    Last Post: 08-16-2008, 12:51 PM
  5. [SOLVED] How to set the frame size?
    By impact in forum New To Java
    Replies: 7
    Last Post: 05-02-2008, 11:57 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
  •