Results 1 to 3 of 3
- 02-15-2013, 12:14 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 24
- Rep Power
- 0
How can I simulate a JTextArea as a text console output?
Sorry for my bad English.
I want to show a large text (more than 6000 lines).
I used setText(String str) and setDocument(Doument doc) methods .
I call these methods from a SwingWorker or SwingUtilities.invokeLater but GUI is frozen.
I'm looking for a way to show the text gradually so the GUI is responsive and the user can stop the process.
Thanks in advance.
- 02-15-2013, 08:12 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Re: How can I simulate a JTextArea as a text console output?
setText ? How do you generate the (600 lines) string?
Why you don`t use the append method from the JTextArea?
- 02-16-2013, 12:23 AM #3
Member
- Join Date
- Apr 2012
- Posts
- 24
- Rep Power
- 0
Re: How can I simulate a JTextArea as a text console output?
@eRaaaa
Thanks for your reply.
I want to make a Web Extractor with Jsoup Library.
I parse a Html document from the web and then I use select(String jquery) method.
The code above is a console demo of how I have so many lines.Java Code:import java.io.IOException; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import org.openide.util.Exceptions; public class JSoupDemo { public static void main(String[] args) { Document doc = null; String url = "http://www.java-forums.org/awt-swing/68936-how-can-i-simulate-jtextarea-text-console-output.html"; int counter = 0; StringBuilder sb = new StringBuilder(); String result; try { doc = Jsoup.connect(url).get(); } catch (IOException ex) { Exceptions.printStackTrace(ex); } //This is the worst case Elements elements = doc.select("*"); //A usefull jquery // elements=doc.select("a"); // Matched elements may include this element, or any of its children System.out.println(elements.size()); // 879 Elements for (Element elem : elements) { sb.append("\n\n(").append(++(counter)).append(")"); sb.append("\n").append(elem.toString()); } result = sb.toString(); System.out.println(result); } }
For my GUI I use Document and JEditorPane.
To improve performance of big texts showing in JEditorPane I also read :
JavaTechniques » Faster JTextPane Text Insertion (Part I)
Slow JEditorPane/JTextPane and performance improvements.
Similar Threads
-
Console like Environment in JTextArea
By Kyle227 in forum AWT / SwingReplies: 4Last Post: 02-25-2011, 07:26 PM -
Need help with printing console output to JTextArea
By ShinTec in forum AWT / SwingReplies: 4Last Post: 06-04-2010, 10:10 AM -
output to terminal instead of console on mac
By firen in forum Advanced JavaReplies: 0Last Post: 06-01-2010, 12:42 PM -
How Do You?? Get the Console Output as a GUI??
By Lyricid in forum AWT / SwingReplies: 10Last Post: 11-20-2009, 11:35 PM -
How to align the output on console?
By sfe23 in forum New To JavaReplies: 5Last Post: 03-30-2009, 03:28 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks