• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.)
 
Marshal
Posts: 79978
397
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Lou Hamers
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Lou Hamers
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You can't expect to wield supreme executive power just because
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic