0

I have a JavaFX application where I want to have some text based control that would show the contents of a growing log file. I can easily implement this with a TextArea and insert at the end while giving the user the option to auto-scroll. This is a long running app with an unbounded number of log messages so I need to be cognizant of the amount of text in the control. I could do this by deleting X characters at the start of the TextArea to roll off older entries but I would like to do this line for line or at least roll off the old on line boundaries. I know I can hack together a solution but is there an elegant way to do this with TextArea or is there some other control that would work better? One additional constraint is that I would like the user to be able to copy text from the log message control.

  • You could use a `ListView` instead of a text area. It would likely perform better, though the UX would be somewhat different. Add log items as objects to the list view's backing list and remove them from the front of the backing list as necessary. Use a cell factory generating uneditable text areas so you can copy text. – James_D Oct 20 '16 at 18:21
  • Possible duplicate of [Most efficient way to log messages to JavaFX TextArea via threads with simple custom logging frameworks](http://stackoverflow.com/questions/24116858/most-efficient-way-to-log-messages-to-javafx-textarea-via-threads-with-simple-cu) – DVarga Oct 21 '16 at 08:45

0 Answers0