• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create this GUI

 
svein kristian nykaas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am wondering what kind of Layout manager is capable of recreating this kind of GUI? I'd very much like it re-sizable but always keep the components like that.

I'm also wondering, how to actually do it even with a layout manager? Do I create 4 JPanels that have been defined how much space they will take over the general window, then add components onto it?

Illustration:
 
Campbell Ritchie
Sheriff
Pie
Posts: 50189
79
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks like a grid bag layout with the left part taking about 3 columns and the right 1 column. The upper part looks like 3 rows and the lower like two rows. Use different widths and heights. Find a copy of Core JavaII by Horstmann and Cornell (vol 1) and find out about the GBC class to assist with grid bag.
If you are adding thigs inside those four spaces, yes. Four panels, each with its own layout.

There are lots of other ways to do it.
 
Bill Krieg
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, a GridBagLayout with 2 columns and 2 rows is appropriate. Set the fill to GridBagConstraints.BOTH for all four subpanels. That will keep all columns in a single row the same height and all rows in a single column the same width.

The first column being wider than the second will happen if the largest preferred size in the first column is wider than the largest preferred size in the second column. The ratio of space allocated to panels in the same row or column is all determined by preferred size of the subpanels.

You can also set the weightx and weighty to handle how resizing should affact the display. Note that the largets weighty for any panel in a given row will determine how much extra vertical space is allocated for each column in the row when the panel is resized vertically. Also, the largest weightx for any panel in a given column will determine how much space is allocated to the column width when the panel is resized horizontally.
 
Bill Johnston
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
svein kristian nykaas wrote:Hello, I am wondering what kind of Layout manager is capable of recreating this kind of GUI? I'd very much like it re-sizable but always keep the components like that.

I'm also wondering, how to actually do it even with a layout manager? Do I create 4 JPanels that have been defined how much space they will take over the general window, then add components onto it?


You could do this just with GridLayout and Borderlayout. Much depends on what Components you place into it, how large each Component is and how you want it to look as it resizes. If you post more detail that will become more clear.
 
svein kristian nykaas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all the answers, I'll be sure to check out the gridbag layout, the examples on oracle pretty much scared me away from it(too much at once), but I'll see if I can't find some easier and better examples.

Bill Johnston wrote:
svein kristian nykaas wrote:Hello, I am wondering what kind of Layout manager is capable of recreating this kind of GUI? I'd very much like it re-sizable but always keep the components like that.

I'm also wondering, how to actually do it even with a layout manager? Do I create 4 JPanels that have been defined how much space they will take over the general window, then add components onto it?


You could do this just with GridLayout and Borderlayout. Much depends on what Components you place into it, how large each Component is and how you want it to look as it resizes. If you post more detail that will become more clear.


I want it to look identical when it resizes, so that all of it remains the same size compared to each other, while being scaled smaller: like this picture:



As you can see, it'll be pretty much the same thing, just smaller.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
another possibility is 3 x JSplitPane
all with resizeWeight set.

you can make the dividers non-moveable,
or hide them etc
 
Bill Johnston
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
svein kristian nykaas wrote:Thanks for all the answers, I'll be sure to check out the gridbag layout, the examples on oracle pretty much scared me away from it(too much at once), but I'll see if I can't find some easier and better examples.

Bill Johnston wrote:
svein kristian nykaas wrote:Hello, I am wondering what kind of Layout manager is capable of recreating this kind of GUI? I'd very much like it re-sizable but always keep the components like that.

I'm also wondering, how to actually do it even with a layout manager? Do I create 4 JPanels that have been defined how much space they will take over the general window, then add components onto it?


You could do this just with GridLayout and Borderlayout. Much depends on what Components you place into it, how large each Component is and how you want it to look as it resizes. If you post more detail that will become more clear.


I want it to look identical when it resizes, so that all of it remains the same size compared to each other, while being scaled smaller: like this picture:



As you can see, it'll be pretty much the same thing, just smaller.


Different Components resize in different ways in different Managers. In some cases you might want to consider no allowing resizing. Using absolute coordinates usually complicate any resizing issues you might have.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want it to look identical when it resizes, so that all of it remains the same size compared to each other, while being scaled smaller

GridBagLayout, all four preferredSizes of [0, 0] and proportional weightx/weighty will do that.
 
svein kristian nykaas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it working using GridBagLayout(sort off, some problems with panels, so I'll have to read up more about those). Thanks for all the great answers!
 
Campbell Ritchie
Sheriff
Pie
Posts: 50189
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell us what the problems were . . . and “you’re welcome”.
 
svein kristian nykaas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is just that I have no idea how to use panels properly, so when starting to introduce it it all got a bit confusing, so all I have to do is to take a step back, focus on panels, then go back towards gridbaglayout while knowing about panels pretty much. For example; not knowing how to paint to a panel etc. However the layout itself I managed to create with using buttons(to illustrate how the panels would look).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic