Amit
Amit

Reputation: 34725

Problem in Java GUI

Before reading about my problem, first look at this GUI Diagram.

There are three bars at the top as follows:

After that two information bars are there.

After that a canvas window displaying the diagram.

Now, I want a GUI similar to this with the following features (relative to the above diagram):

I had tried to implement it by first having a "main panel" with BorderLayout. After that as showing in the following figure:

mainPanel(Border Layout)
|
|--topPanel (at NORTH of the mainPanel's Border Layout)
|
|
|--centerPanel (at CENTER of the mainPanel's Border Layout)

topPanel - to contain all the bars (bars should be added dynamically when a user clicks on a button)

centerPanel - to contain the canvas and adjust its size automatically when new bars are added in the topPanel

Upvotes: 0

Views: 322

Answers (2)

Eugene Ryzhikov
Eugene Ryzhikov

Reputation: 17359

The other alternative is to go with MigLayout where you can add as many components as you need to the "top". By setting "hidemode" parameter you can specify how space will occupied by invisible components.

In general MigLayout is much more flexible for almost any task and can be used instead of any standard layout or combination of layouts

Upvotes: 0

Carl Smotricz
Carl Smotricz

Reputation: 67750

I would use a BorderLayout for the app, with the toolbars in a northerly pane.

That north pane I'd give a vertical BoxLayout and put the 3 toolbars into 3 successive boxes. That should take care of the geometry.

I'm not sure if making a toolbar invisible will cause it not to occupy space, but that would be the simplest. Alternatively, you could dynamically add()/remove() toolbars from the north pane.

Upvotes: 2

Related Questions