Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

everything displaced in full screen scene builder

 
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i made a nice user interface which looks great in the window
but when i maximise the window everything goes to the top left
how can i keep it relative to how it looks in the small window?
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is in the preview in scene builder do you change this in code of the application or is it settings in scene builder itself?
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
found this:
https://stackoverflow.com/questions/33095166/javafx-resize-components-when-fullscreen

and it says you shouldnt use an anchorpane (which i am)
rather use a vbox or a gridpane

the problem is i cant align my images text boxes etc with these two as nicely as the anchorpane
it only lets you line up to areas which is terrible

how do you line things up the way you want? ie freely
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why do borderPanes and the other layouts have regions where you can put things and not move them around?
what should i be using to do this?
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what does this mean?

It appears that I am using Group as a root for my Scene. As said in JavaFX documentation: "If a Group is used as the root, the contents of the scene graph will be clipped by the scene's width
and height and changes to the scene's size (if user resizes the stage) will not alter the layout of the scene graph".
 
Sheriff
Posts: 6106
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Wayne.

I'm just guessing at what you don't understand about that sentence, but a Scene Graph is all the controls and containers in the Scene.  So a Group container will just give you a single size that will be clipped if you resize.

You don't have to use an Anchor Pane, but that is one of the panes that will resize.

You might want to post the FXML file here so we can look at it.
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i just used a normal Pane as its a very basic login screen,is that resizeable?


 
Knute Snortum
Sheriff
Posts: 6106
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a very simple GUI that resizes oaky (resizing is a bit of an art).

Notice that there is very little absolute positioning (put this at x = 9 and y = 3, e.g.)  That will run into trouble.
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whats the best thing to use for a basic screen?
like an image in the background with a couple of buttons etc?
that you can freely move nodes around without being constrained to an area?
 
Knute Snortum
Sheriff
Posts: 6106
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, again, if I understand you correctly, if you use absolute positioning, you will lose the ability to resize well.  It's a trade-off.
 
Knute Snortum
Sheriff
Posts: 6106
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

wayne brandon wrote:ok i just used a normal Pane as its a very basic login screen,is that resizeable?


No, for two reasons.  One, you are using absolute positioning.  Two, I don't think Pane is a container that will resize -- but I could be wrong.

Try thinking of putting containers inside containers to get the layout you want.
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so what should i use the grid one or vbox?

i attached a screen shot of the login box its pretty basic

if i wanta login screen and then another screen for the main program is it all in the one javafx program or do you create them separately and then connect them?

 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
screen shot of the login i want
really basic

would like to keep the usernames and passwords in a database

nice little project
login.PNG
[Thumbnail for login.PNG]
 
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks easy enough, set your anchorpane(or what ever pane you use) to center (add properties) add a vbox do the same, add an image view, label and two textfields, you can play with the top and bottommarges of your nodes to get the layout you want. If you wan't to make sure that the layout dosn't change (if you use center it shouldn't mater how big your window is) you can set vgrow in the layout tab to never.
BTW make sure your vbox is the same size of your pane.
If you want to be really lazy you can remove the two textfield of your login png and set it as background, then you only have to add the two textfields
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're interested I can help you set up your project to use springBoot together with javaFx, it will make the use of a db a lot easier...
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for sure!!! 100% that would be great!!! amped!!!
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"If you want to be really lazy you can remove the two textfield of your login png and set it as background, then you only have to add the two textfields"

thats how i have it its not on the png its text fileds
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step one set up a new maven project or you could use springInitializer if you like to.
If your setting up your own, add the needed dependencies.
Then there are 3 things you'll need to do to make everything work.
First of all in your mainClass you need a static springcontext and static stage, you'll need thoose to easly switch scenes in your project later on, I wrote two utility methods for that which I'll share with you, the rest of your mainClas is pretty standard settup for springBoot and javaFx. Something like:

Secondly write a ultilitymethod to change the scene or get a new scene, change the scene will open a new fxml file in the same window, getting a new scene opens a new window, kinda like a popup, handy for dialogs or something like that:

ChangeScene:

New Stage:

And finally you need an other utility method that adds a bean to the springcontext:

Now you can use your program as an javaFX program with all the advantages of SpringBoot. I have a base program that I always reuse when I start a javaFxproject, That already includes the utilitymethods and basic setup.
If you want I can share it on git, then you only need to add your dbCreditentials to the application.properties, update the pom a bit and your good to go...
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set your anchorpane(or what ever pane you use) to center (add properties)

is a pane ok?

i dont see where to set the pane to center (add properties???) can you explain more

sorry daniel
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that would be great,please share
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One final note, you might notice that when I change the scene I show the window in the utlity method, while when opening a new window, I return it.
That has a verry good reasson, it's easier to close the wndow if I return it.
To change the scene you just call:

To open a new window:

Keep in mind when using this setup, your relative path start from your resourcefolder, so I keep my fxmlfile in a subfolder of resources
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Knute

ok i just used a normal Pane as its a very basic login screen,is that resizeable?


No, for two reasons.  One, you are using absolute positioning.  Two, I don't think Pane is a container that will resize -- but I could be wrong.

Try thinking of putting containers inside containers to get the layout you want.

will keep this in mind
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

wayne brandon wrote:set your anchorpane(or what ever pane you use) to center (add properties)

is a pane ok?

i dont see where to set the pane to center (add properties???) can you explain more

sorry daniel


My bad it's in layout, the second tab on the right handside
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setup on git
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks daniel i downloaded it and captured your posts for studying thanks alot really appreciate it.
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:
Try thinking of putting containers inside containers to get the layout you want.


That's is actually a verry good tip, I also always use a pane (most of the time a borderpane, cause it's easier to import your menu on the top and footer in the bottom), then a vbox inside my pane and then a bunch of hboxes nested in my vbox
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my alot

alot.PNG
[Thumbnail for alot.PNG]
 
Knute Snortum
Sheriff
Posts: 6106
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

wayne brandon wrote:so what should i use the grid one or vbox?

i attached a screen shot of the login box its pretty basic


You could use either.  It mostly depends on how you're think about the layout.  Are the title and two text fields all centered with the image above?  Or are they all vertically stacked with some space at the bottom?

I think I would try VBox first and then Grid, at the former is easier than the latter.  You could also use a BorderPane with a VBox in the middle and the image on top.

In Scene Builder there is a preview window you can launch and play with.  On mine it's Preview > Show Preview in Window.

if i wanta login screen and then another screen for the main program is it all in the one javafx program or do you create them separately and then connect them?


I have a way to do this, but if you're going to use SpringBoot as Daniel suggested, I'd go with that.
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use my springboot setup you can use SpringBoot security to handle your login, my guess is that's also what knute is talking about, alternatively, if you want to handle the login yourself, you can create your own logic using the NewStage class to show the loginform
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Daniel i really dont know what im doing with your download
i imported the maven project but i cant do anything with it

maybe im jumping the gun here, im too inexperienced at this stage. But what can i do to start really basic with scenebuilder javafx?
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok got a bit further navigated down to the main class in src but it isnt running ..i dont think i have spring installed

will check that out
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Weird... I'll post a instruction video in a sec. For the basic, there are a couple of easy tutorials by the new boston on youtube, that's how I started out
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im running intelij community i dont think it supports spring

think i will move to netbeans, or is there a better free ide?
eclipse?
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
3 Things I can think about:
- Did you change the application.propeties to use you db? It has a mysql and springBoot.jpa dependency in the pom, so it expects you to configure a datasource.
- It could be you still have to import it as an maven project, to do so right click you pom and select add as maven project
- This is written in java 8, when javaFX was still part of the jdk, if you're using 11 (I think 10 was the last one that included it), you will have to do adittional changes
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

wayne brandon wrote:im running intelij community i dont think it supports spring

think i will move to netbeans, or is there a better free ide?
eclipse?


your dependencies have nothing to do with wich ide you use, somepoeple say netbeans is better suited for javaFX, but for me there's no ide other then intellij.
Eclipse isn't fully free eather, you will also have to run some kinda community version, I don't know about netbeans, installed it onces, but wasn't a big fan
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do i have to have mysql installed?
 
wayne brandon
Ranch Hand
Posts: 258
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
icant read on the video,its really small also my file looks different,does that matter?
thanks so much daniel
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you wan't to use a Mysqldb... Alternatively for now you can remove the dependencies out of your pom and remove the settings for your datasource in your application.properties
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!