Results 1 to 6 of 6

Thread: Stop Objects from Resizing in Swing?

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Stop Objects from Resizing in Swing?

    I'm working on the following swing GUI for a project:

    What I want to do is make it so the "Simulation Options" don't resize at all, but just stay the same size and don't move when the whole frame is resized. How can I accomplish this?

    The "Simulation Options" is a JPanel with a GridLayout.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Sounds like you want the layout manager to honor the components preferred size. Normally when you don't want a component to stretch out when its container is resized you can add it to a panel then add the panel to a the container. JPanels use the flowlayout manager which does not ignore the componets preferred size as GridLayout does.

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Not sure I follow.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Sorry i was assuming that you had a component inside the JPanel that you didnt want resized with the JFrame was resized. Why not keep the frame from being resized in the first place?

  5. #5
    Banned debbie_82's Avatar
    Join Date
    Jan 2004
    Location
    inside a hollow void
    Posts
    104
    well u could use absolute positioning of the components.. if u don't want the components to be resized... if it does no include moving of components also.

  6. #6
    Banned debbie_82's Avatar
    Join Date
    Jan 2004
    Location
    inside a hollow void
    Posts
    104

    Re: Stop Objects from Resizing in Swing?

    Originally posted by The Hobo
    I'm working on the following swing GUI for a project:

    What I want to do is make it so the "Simulation Options" don't resize at all, but just stay the same size and don't move when the whole frame is resized. How can I accomplish this?

    The "Simulation Options" is a JPanel with a GridLayout.
    oops I didn't read that one... gridLayout hmmm.

    why don't u use SpringLayout then? on the part of the buttons that is.

Posting Permissions

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



Click Here to Expand Forum to Full Width