Results 1 to 3 of 3

Thread: JPanel/JFrame

  1. #1
    Mayur is offline Member
    Join Date
    Jan 2009
    Posts
    24
    Rep Power
    0

    Default JPanel/JFrame

    Hello all. I am trying to setup a JPanel inside a JFrame. The trouble I'm having is that I need to make a fixed content window size but when I use the setSize() method, it sets the size of the entire window including the border and Windows minimize/maximize/close buttons. Is there any way where I can set the size of the content area and not the entire window?

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default

    I suggest you read the Swing tutorial on "Using Layout Managers". This is a fundamental concept when using layout managers. You should NOT be using setSize. The basic code is:

    Java Code:
    panel.setPreferredSize(...);
    frame.add(panel);
    frame.pack();
    frame.setVisible(...);

  3. #3
    Mayur is offline Member
    Join Date
    Jan 2009
    Posts
    24
    Rep Power
    0

Similar Threads

  1. How to add JFrame inside JPanel
    By niteshwar.bhardwaj in forum Java 2D
    Replies: 8
    Last Post: 12-13-2009, 08:41 PM
  2. JFrame and JPanel -Error
    By britto_bicsjohn in forum AWT / Swing
    Replies: 2
    Last Post: 08-25-2009, 01:31 PM
  3. JFrame and two JPanel Classes
    By YellowPainting in forum AWT / Swing
    Replies: 9
    Last Post: 08-25-2009, 12:49 PM
  4. problems with JPanel and JFrame
    By v1nsai in forum New To Java
    Replies: 13
    Last Post: 04-08-2009, 07:49 PM
  5. scroll a Jpanel in a JFrame
    By nidhirastogi in forum SWT / JFace
    Replies: 1
    Last Post: 09-07-2008, 03:42 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
  •