Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I Search a simple JTextPane with best performance  RSS feed

 
Fabio Cr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have developed a JAVA tool (oppure Java Tools) to monitor data on serial line. In order to view traffic data I use a JTextPane, as I need to change the text colour. The problem is that when I receive many data at high speed the insertString method is very slow.
I am asking therefore, if there is a simpler class with the following characteristics:
- High performance;
- Scroolable text area;
- I need only one font;
- change text colour (two colours at the same time);
- select and copy part of text;
- apply a KeyListener;
- i don't need to insert the string, i only need to append the string;
- delete part and whole text;
Do you know if exist some class for make this?
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How often are you appending to the JTextPane? It might be better to buffer the data in a StringBuffer (or StringBuilder if using JDK 1.5), and then just do one append every so often (perhaps every time the colour changes, you dump the previous information).
 
Fabio Cr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I append data every 250mS from a StringBuffer (is a thread that read from InpuDataStream and append to StringBuffer) or when change the color. The number of byte is variable from 1 to 3000 (in function of the baud rate and in function of the application in monitoring).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!