aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to create this GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to create this GUI" Watch "How to create this GUI" New topic
Author

How to create this GUI

svein kristian nykaas
Greenhorn

Joined: Apr 15, 2012
Posts: 11
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

Joined: Oct 13, 2005
Posts: 39834
    
  28
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

Joined: Jul 31, 2011
Posts: 9
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

Joined: Nov 17, 2005
Posts: 201
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.


~Bill
svein kristian nykaas
Greenhorn

Joined: Apr 15, 2012
Posts: 11
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

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Nov 17, 2005
Posts: 201
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

Joined: May 03, 2008
Posts: 4658
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
svein kristian nykaas
Greenhorn

Joined: Apr 15, 2012
Posts: 11
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

Joined: Oct 13, 2005
Posts: 39834
    
  28
Please tell us what the problems were . . . and “you’re welcome”.
svein kristian nykaas
Greenhorn

Joined: Apr 15, 2012
Posts: 11
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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create this GUI