hello i'm beginner in java language ... so my problem is that i want to make a thread typing in jtext area but i have no idea how to do that
i use netbines IDE
this is my code:
class md2:
import java.util.logging.Level;
import java.util.logging.Logger;
public class md2 implements Runnable{
public void run(){
int i=0;
while(true){
System.out.println("méthode 2 : "+i++); // that what i want to typing in the jtextarea
try {
Thread.sleep(200);
} catch (InterruptedException ex) {
Logger.getLogger(md2.class.getName()).log(Level.SEVERE, null, ex);
}
}
}}
and this is my jframe :
public class tp3 extends javax.swing.JFrame {
public tp3() {
initComponents();
}
md2 m1=new md2();
Thread cp3 =new Thread(m1);
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
tx = new javax.swing.JTextArea(); // this is where i want to typing
tx.setColumns(20);
tx.setRows(5);
}// </editor-fold>
private void sMouseClicked(java.awt.event.MouseEvent evt) {
cp3.start(); // button to start the thread
}