This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

JavaFX/SceneBuilder Question - "Drag Library Items Here"

 
Ranch Hand
Posts: 69
IntelliJ IDE Eclipse IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I just open Scene Builder, it gives me an outline around the Anchor Pane and the "drag library items here" verbiage. If I right-click on my FXML file and "Open with SceneBuilder" the Anchor Pane remains invisible, unless I double click to populate a control in it. At that point, all I can see is the control.

Next, when I have all of my controls positioned, and I run my application, I find my GUI doesn't resemble what I designed. Oh, everything is nominally in place, but the proportions an positions are all off.

Any insight would be very welcome.
 
Sheriff
Posts: 6261
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Douglas Knapp wrote:If I just open Scene Builder, it gives me an outline around the Anchor Pane and the "drag library items here" verbiage.


This sound like you've just opened an empty project.  There is no AnchorPane until you add one.

If I right-click on my FXML file and "Open with SceneBuilder" the Anchor Pane remains invisible, unless I double click to populate a control in it. At that point, all I can see is the control.


Again, no AnchorPane, but besides at, this seems like normal behavior.

Next, when I have all of my controls positioned, and I run my application, I find my GUI doesn't resemble what I designed. Oh, everything is nominally in place, but the proportions an positions are all off.


This is odd.  The only thing I can suggest is to press Ctrl-P in SceneBuilder, or pull down the Preview menu and select Show Preview in Window.  Do the proportion and positions look correct?
 
Douglas Knapp
Ranch Hand
Posts: 69
IntelliJ IDE Eclipse IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:This sound like you've just opened an empty project.  There is no AnchorPane until you add one.



No, SceneBuilder indicates there is an AnchorPane. It shows in my Hierarchy tab. It's just invisible. Having read your reply, however, prompted me to attempt what should have been obvious to me. I deleted the AnchorPane that was already there, and I added a new one. It was visible.

Knute Snortum wrote:This is odd.  The only thing I can suggest is to press Ctrl-P in SceneBuilder, or pull down the Preview menu and select Show Preview in Window.  Do the proportion and positions look correct?

Didn't know I could do that. Trying it now... Looks like what I designed. Give me a minute or twenty and I'll see wht it looks like when I run it.

 
Douglas Knapp
Ranch Hand
Posts: 69
IntelliJ IDE Eclipse IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I got it to work. The only issue I now have is my label.

In SceneBuilder I set the textAlignment to center. If you look in my FXML, it shows this.



When I run the app, the text in the label is still left-aligned.

My Java:


My FXML:


Other than that, it works correctly.
 
Knute Snortum
Sheriff
Posts: 6261
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't executed the code yet, but I suspect that the text inside the label is centered, but the label is not.  Try extending the size of the label to the full width.
 
Knute Snortum
Sheriff
Posts: 6261
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, my guess was wrong.  You had the label centered but not the text inside it:
 
I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!