Results 1 to 4 of 4
  1. #1
    archanaanbu is offline Member
    Join Date
    Feb 2011
    Posts
    21
    Rep Power
    0

    Default jpanel in jframe-pls help

    Hi,
    Am doing an application in netbeans. I have jpanel inside jframe. If i run it jpanel always comes left side though i changed space around. I want jpanel to come center of jframe when i run it. where to change resolution for this? please help.

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by archanaanbu View Post
    Hi,
    Am doing an application in netbeans. I have jpanel inside jframe. If i run it jpanel always comes left side though i changed space around. I want jpanel to come center of jframe when i run it. where to change resolution for this? please help.
    try

    yourFrameInstance.getContentPane().add(yourJPanel, BorderLayout.CENTER);
    Last edited by j2me64; 02-11-2011 at 02:08 PM.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Since you're using NetBeans, who knows what layout manager your JFrame's contentPane is using, and j2me64's advice will only work if is using Borderlayout (and even this is not a guarantee). Your best bet is to read up on how to use layout managers in the Swing tutorials.

  4. #4
    archanaanbu is offline Member
    Join Date
    Feb 2011
    Posts
    21
    Rep Power
    0

Similar Threads

  1. Jpanel and Jframe help!!
    By Java_n00b in forum AWT / Swing
    Replies: 4
    Last Post: 01-23-2011, 04:05 PM
  2. JFrame and JPanel
    By khiat in forum New To Java
    Replies: 6
    Last Post: 01-15-2011, 07:32 PM
  3. Help with JPanel and JFrame
    By weikang in forum AWT / Swing
    Replies: 3
    Last Post: 11-26-2010, 01:22 AM
  4. JPanel/JFrame
    By Mayur in forum New To Java
    Replies: 2
    Last Post: 12-20-2009, 05:07 AM
  5. JFrame and two JPanel Classes
    By YellowPainting in forum AWT / Swing
    Replies: 9
    Last Post: 08-25-2009, 12:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •