Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I implement a status bar at the bottom of a resizable application?

895831Oct 23 2011 — edited Nov 15 2011
Hello all,

I am a JavaFx newbie and I am implementing an application (a Sokoban game), with a menu at the top of the frame and a gaming area covering the rest of the frame. To support the game, I have to load images at certain positions in the gaming area.

The game also includes a level editor with another menubar and where images are set to other positions.
I implemented this in another view, swiching from the game mode to the level editor mode and vice versa is just done by setting the other view visible. Up to now this works, here the important statements building these details:
Group root = new Group();
gameView = new Group(); // for gaming mode
le_view = new Group()   // for level editor mode
MenuBar gameMenubar = new MenuBar();
Menu menuGame = new Menu(bundle.getString("MenuGame"));
... building the menu items and menues ...
gameView.getChildren().add(gameMenubar);

ImageView buildingView[][] = new ImageView[22][22];
for (nCol = 0; nCol < 22; nCol++) {
    for (nRow = 0; nRow < 22; nRow++) {
        buildingView[nCol][nRow] = new ImageView();
        buildingView[nCol][nRow].setX(nCol * 26 + 5);
        buildingView[nCol][nRow].setY(nRow * 26 + 40);
        gameView.getChildren().add(buildingView[nCol][nRow]);
    }
}
gameView.setVisible(true);
root.getChildren().add(gameView);

... same stuff to build the le_view ...

le_View.setVisible(false);
root.getChildren().add(le_View);
Scene scene = new Scene(root, 800, 600, Color.CORNSILK);
Now I want to introduce a status bar at the bottom of the frame, which of course has to follow the bottom of the frame, if it is resized. And of course the menu and the status bar should not grow vertically, if the height of the frame is increased.

The implementation seems to be easy with StackPane for the frame and one BorderPane for each mode.
For the first step I only tried implementing the game mode with only one BorderPane (just setting the menu, the gaming area and the status bar each into a HBox and setting these three HBoxes at the top, into the center and at the bottom). I also tried this via GridPane and via VBox; I always get any erroneous behaviour:

Either the menubar is visible, but the menus do not pop up the menu items, or the anchor point of the menu and of gaming area are set 100 pixels left of the left frame border and move into the frame when the frame width is increased, or the menu is set 20 pixels below the top of the frame, or HBox with the menu grows when the frame height is increased, so that the anchor point of the gaming area moves down.

Can you describe me a correct construction of such a frame? Thanks in advance.

Best regards
Gerhard
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 13 2011
Added on Oct 23 2011
3 comments
8,559 views