This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

update textarea and scroll

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi.
in my initialize method, i've:

of TextArea object, and:


logString is SimpleStringProperty, that I change:


well...
when variable logString change the content of textarea change with the value of logString, i see "i'm here two" in the console but not "i'm here" in the textarea and it isn't scroll at the bottom... WHY ???


 
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. You can't modify a unidirectionally bound property (only the thing the property is bound to can change it).

To see an example, run the following program:

Output will be:

java.lang.RuntimeException: A bound value cannot be set.



So your program throws an exception and you never catch it, so you never know.

Note, you can modify a bidirectionally bound property, in which case both properties will change their values.

2. Even if modifying the property did work, your program would go into an infinite loop.

You listen for changes on the property, then always change the property when the property changes, so it will be forever changing.
 
Max Pic
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok. thanks.
i've modified my code in initalize method:



it now works. but i ask: is it the best way to update (and scroll) javafx textarea?


2nd question:
when i update logString variable, I must to use "Platform.runLater" or not?

 
John Damien Smith
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> is it the best way to update (and scroll) javafx textarea?

I wouldn't use a textarea for to implement a logging component in JavaFX, I would use a listview, add each log entry as an item to the collection backing the listview and scroll the listview to the item.

> update logString variable, I must to use "Platform.runLater" or not?

If logstring is being updated on the JavaFX application thread, then runLater is not required, otherwise you need to wrap updates to it in platform.runlater so that it is updated on the JavaFX application thread.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic