Win a copy of Raising Young Coders: A Parent’s Guide to Teaching Programming at Home this week in the General Computing forum!
Forums Login/signup

Javafx, how do I create a GUI that fits everyone in full screen mode?

+Pie Number of slices to send: Send
I have a problem since 3 days, I am supposed to create a window in fullscreen mode, where a self-made GUI is running in the background.

The problem I have is that no matter how I create the GUI or resize it to fit my screen in full screen mode, if someone else opens full screen mode and they have a much larger screen, the GUI is not on the full window.

Does anyone have any idea how to solve this?

I currently use Scenebuilder to create the layout, but can do without it if it can be done with Javacode.

(Sorry I can't include any code here myself, my problem is that I don't know what to include here at all, as I mentioned I don't have an approach.)
1
+Pie Number of slices to send: Send
Welcome to the Ranch

I have forgotten almost all the FX I ever knew, but surely there is a method to get the size of the display. Then can you use those sizes for the size of the display?
+Pie Number of slices to send: Send
I'm not sure how to answer this question, without something to work with. This is the kind of thing that doesn't have a single answer, "how" depends on the specifics of what components you're working with and especially how you want to design and structure your interface (possibilities are endless...)

I guess you're talking about Responsive Design? Yep you can do this. But there is a little learning curve to get the hang of it.

You can get most (if not all) of this accomplished using Scene Builder. Below is an example I just tossed together quickly which demonstrates a few "tricks". One of my favorite techniques involves VBox/HBox combinations with hgrow and vgrow values on their child containers (I used a basic Pane in the below example to achieve a "spacer" effect).

For the most part though, most JFX components will already attempt to size themselves appropriately. And you usually want to stay as close to that as possible (only override and hardcode stuff when you need to). You don't need to use an AnchorPane as the root, that's just what SceneBuilder defaults to (I rarely use AnchorPane really, often a BorderPane or even a simple HBox/VBox are better.)



If that's not what you meant, there's also this boolean setting on Stage that you might be interested in:



This is just a preview, I actually resized it smaller than the default, but the principle is the same and the components change their spacing for larger window sizes too.



Once you have something more concrete (especially some kind of design or layout at least in mind), you can ask for some more specific (and probably more helpful) suggestions.
+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:Welcome to the Ranch

I have forgotten almost all the FX I ever knew, but surely there is a method to get the size of the display. Then can you use those sizes for the size of the display?



Yeah there's a class called Screen where you can discover that stuff, although I'd definitely advise trying to design such that you don't need to know how large a user's resolution is, if possible. If you need to support multi-monitors it could be pretty useful though...



I'm sure you could also use whatever the Swing guys use too, but I've also forgotten about that. lol
+Pie Number of slices to send: Send
 

maximilian manduva wrote:
I currently use Scenebuilder to create the layout, but can do without it if it can be done with Javacode.



Ok last one, I just noticed this... the complexity and dynamicity of your design impacts whether you should* use Scene Builder/FXML. IMO it definitely helps when you're trying to do Responsive Design, especially when learning.

*It's really up to personal preference...

But ultimately you don't need FXML. FXML is just another way to do lots of component creation and to add children to components. i.e. it's a whole bunch of "new Whatever()" and "getChildren.add(whatever)" statements expressed in a hierarchical format which is easy for an application like Scene Builder to parse and edit. (Also a bunch of set(whatever) calls too.)

Personally I usually use Scene Builder heavily, unless I'm doing something very dynamic where the UI is being constructed on the fly.
+Pie Number of slices to send: Send
Outside of personal preference, there's no reason not to use FXML though. It really cleans up your code, and for the parts you can't configure in FXML, you can still use a procedural approach after the components have been injected.

Anyway, I'm getting the feeling that Maximilian's question is not about responsive design, but rather that they can't get full screen mode working consistently.

Maximilian, you need to show us the code you're using to go into fullscreen mode. I have the feeling you're just trying to resize the window, without going fullscreen properly.

reply
reply
This thread has been viewed 6179 times.
Similar Threads
JavaFX - which layouts to use for this mockup
Problem with fullscreen
Newbie, Absolute Layout Question
How to Make JavaFX-Scene fit MSWindows Size?
Making GUI for programs
More...

All times above are in ranch (not your local) time.
The current ranch time is
Jun 27, 2025 08:51:59.