This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Beginner JavaFX

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I was messing around with a code I found on pastebin, and was trying to change my label Show Colors based on me moving the scrollbar from right to left, as well as input in my textfield. I've gotten that to work, but I can't seem to get the label position correctly and I have to make the scroll-bar settings display in only two decimal places. I just learned javafx this week for class and while I don't want to answer, it would any help figuring out on what I did wrong would be greatly appreciated.




The goal is to make my JavaFX project look something like this.



As opposed to this, specifically with the labels.

 
Blake Ryan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any tips for this?
 
Greenhorn
Posts: 4
IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
you seem to have used StackPane in which you add your "Show colors" label but the deal with StackPane is that its nodes will be layered on top of each other, as if you were looking at a stack of paper from a birds eye view.
Try reading up on other javafx panes, namely VBox

As for formatting the values in your textfields, the method .asString() for your bindings seems to accept a format in which to display the given value. Formatting rules can be found at java.util.Formatter
 
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use a TextFormatter for formatting the text in the TextField.

https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TextFormatter.html
http://stackoverflow.com/questions/31039449/java-8-u40-textformatter-javafx-to-restrict-user-input-only-for-decimal-number
http://stackoverflow.com/questions/35093145/string-with-numbers-and-letters-to-double-javafx/

You could also review this sample, (though it is a bit dated, and nowadays probably new API such as TextFormatter would be a better implementation):
https://gist.github.com/jewelsea/1962045 "JavaFX example of binding a slider value to a Label or editable TextField."
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic