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!

GridPane takes up entire scene

a380205e-cd56-4202-ae1d-43b51c3e7c8eJan 12 2016 — edited Jan 13 2016

Hello all. I'm very new to javaFX (24 hours new), but I used to spend a lot of time with Swing. I'm working on a UI/game whose main content will always remain centered in the window at a 16:9 aspect ratio. I tested this with a BorderPane as my root parent. Then added a StackPane as the center node (I'll be adding layers on this centered content so StackPane seems perfect). I then added a Rectangle to the StackPane and dynamically resized it based on the BorderPane using the "layoutBoundsProperty().addListener" method. Everything looked great. The centered rectangle would get as big as it could in the scene without losing the proper proportions.

I now wanted to replace this test Rectangle with a GridPane to start working with some real components in my centered content. However, adding even an empty GridPane takes up the ENTIRE scene. I would expect it to stay centered and only take up as much space as it needs (so empty would be invisible???) based on whatever nodes are inside of it.

Perhaps my entire approach is wrong as my end goal is to have all content in the StackPane tree of nodes resize proportionally based on the window size. The old Swing coder in me used to just render using Graphics2D to a BufferedImage and draw that onto my JFrame/Canvas at whatever size I needed at the moment. Any thoughts on how to accomplish this goal, or clarification on what I'm not understanding about the GridPane added to a BorderPane-centered StackPane?

Thank you,

Andy

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 9 2016
Added on Jan 12 2016
0 comments
650 views