Note that there are some explanatory texts on larger screens.

plurals
  1. POJTextArea not displaying text
    primarykey
    data
    text
    <p>In my function for displaying text in textarea,i have written following lines of code but it is not displaying any text</p> <pre><code> jTextArea1.setText( Packet +"\n" +jTextArea1.getText()); </code></pre> <p>I am using swingworker for performing background task,here is my code</p> <pre><code>public class SaveTraffic extends SwingWorker&lt;Void, Void&gt; { public GUI f = new GUI(); @Override public Void doInBackground() throws IOException { //some code sendPacket(captor.getPacket().toString()); return null; }//end main function @Override public void done() { System.out.println("I am DONE"); } public void sendPacket(String Packet) { f.showPackets(Packet); } </code></pre> <p>}</p> <p>and the following lines of code i have written in my GUI form</p> <pre><code> public void showPackets(String Packet) { jTextArea1.append( Packet); } </code></pre> <p>Solution: public class SaveTraffic extends SwingWorker {</p> <pre><code> public GUI f = new GUI(); @Override public Void doInBackground() throws IOException { f.add(jTextPane1); // some code publish(captor.getPacket().toString()); // the method below is calling sendPacket on the background thread // which then calls showPackets on the background thread // which then appends text into the JTextArea on the background thread //sendPacket(captor.getPacket().toString()); return null; } @Override protected void process(List&lt;String&gt; chunks) { for (String text : chunks) { jTextPane1.setText(text); f.showPackets(text); } } @Override public void done() { System.out.println("I am DONE"); } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload