Results 1 to 4 of 4
  1. #1
    AcousticBruce is offline Senior Member
    Join Date
    Dec 2010
    Location
    Indiana
    Posts
    202
    Rep Power
    4

    Default JPanel getSize() getWidth(); also force maximum size?

    I have a Jpanel that has a BorderLayout.WEST and CENTER.

    I would like the CENTER JPanel (has overridden paint component) to use All available space for the X size. Right now I have a custom setPreferredSize and I do not want to set the X size.

    1 ) How can I have the X Dimension fill whats left of the X size?

    2) If above isnt possible perhaps I can take the main JPanel getWidth() and subtract the WEST JPanel and use that number as the X Dimension. Is this possible?

    note: I keep getting 0 for the returns for all getWidth() and getHeight(). I was successful once when I put the method in the overridden paintComponent.

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

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    I'm not visualising what you want. It sounds like you have:
    Java Code:
    *************************
    *        *              *
    *        *              *
    *        *              *
    *        *              *
    *************************
    What do you want instead?
    Last edited by Junky; 02-23-2011 at 04:17 AM. Reason: Where's the preview button.

  4. #4
    AcousticBruce is offline Senior Member
    Join Date
    Dec 2010
    Location
    Indiana
    Posts
    202
    Rep Power
    4

    Default

    Junky you have it exactly right.

    I would like the X Dimension only to change. Is this possible? My was was just getWidth of main Jpanel minus the getWidth of WEST JPanel. what do you think?


    You might want to create and post an SSCCE so we can see exactly what you mean.
    Fubarable I am not ready for a SSCCE yet. I will try for this if I cant find a simple way to get the getWidth() method to work.

Similar Threads

  1. get maximum heap size that can be allocated
    By gautam.aditya97 in forum Java 2D
    Replies: 3
    Last Post: 04-05-2010, 05:03 AM
  2. Maximum size of POST to Servlet
    By Ward in forum Java Servlet
    Replies: 0
    Last Post: 03-04-2009, 11:35 AM
  3. Replies: 2
    Last Post: 07-03-2007, 04:09 PM
  4. How To:Use a JSlider to adjust Text size in a JPanel
    By louiebagz in forum AWT / Swing
    Replies: 2
    Last Post: 07-01-2007, 07:37 AM
  5. Maximum size of an array
    By Hasan in forum New To Java
    Replies: 1
    Last Post: 05-20-2007, 11:11 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
  •