Results 1 to 4 of 4

Thread: Layout problem

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

    Default Layout problem

    I have been experimenting with layouts (border, flow, grid), but I still don't know how to get the result from my task.

    My task is to organize components in a way shown in the attached picture. (calc.jpg) To be precise, while resizing a window horizontally components mustn't change their width, and space between all of the components has to be equal.

    I tried to use FlowLayout. Size of my components doesn't change while resizing, but they are located in a centre. While resizing window, space between them is constant whereas a space on the left and on the right is getting bigger.

    I tried to use BorderLayout. I located one component at west, another one at east, but the one at the centre filled the whole free space, eliminating any spaces. While resizing window a component in a centre was growing.

    I tried to use GridLayout with a constant space between components. While resizing space between them is constant, but the components are getting bigger.

    Summing up. I would like to get a layout in which one component is at the left side, another one at the right side, the other components are between them, components don't change their size while resizing window and space between each component is the same and increases while resizing window.

    Thanks in advance.
    Attached Thumbnails Attached Thumbnails Layout problem-calc.jpg  

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

    Default

    You will need to use a combination of layouts by nesting JPanels, each one using its own layout. The button grids would be placed in a JPanel that uses GridLayout, and you'd likely need 4 JPanels for this, one for each cluster of JButtons. Then you could place these JPanels into a larger JPanel that uses BoxLayout oriented BoxLayout.PAGE_AXIS.

    The key to figuring this out is to experiment with different variations.

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

    Default

    Quote Originally Posted by Fubarable View Post
    JPanel that uses BoxLayout oriented BoxLayout.PAGE_AXIS.

    That's what I was looking for.
    Thanks a lot!

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

    Default

    Quote Originally Posted by miller.bartek View Post
    That's what I was looking for.
    Thanks a lot!
    You're welcome, but note that my suggestions were just that -- suggestions. There are many other and perhaps better ways to lay this out. Regardless again the key is to experiment.

Similar Threads

  1. problem in managing layout
    By namreen in forum NetBeans
    Replies: 10
    Last Post: 09-04-2010, 10:41 AM
  2. java on mac - gui layout problem
    By dalo in forum AWT / Swing
    Replies: 0
    Last Post: 06-19-2010, 11:15 AM
  3. I have a problem in setting layout for panel.
    By Vin in forum AWT / Swing
    Replies: 5
    Last Post: 01-19-2010, 11:22 AM
  4. Layout problem / add components from another class
    By ehochedez in forum AWT / Swing
    Replies: 9
    Last Post: 09-02-2009, 11:42 AM
  5. [SOLVED] Layout Problem
    By casid in forum New To Java
    Replies: 4
    Last Post: 06-03-2009, 12:17 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
  •