Salut
D'accord avec Dragon, ca a pas beaucoup d'interêt
mais (lol) voila un petit truc que je viens d'essayer pour rediriger le System.out sur un JTextArea
on fait une classe extends OutputStream qui écrit dans un JTextArea
ca semble marcher
import javax.swing.*;
import java.io.*;
public class OutJTextArea extends OutputStream {
JTextArea textArea = new JTextArea();
public OutJTextArea() {
}
public void write(int b) throws java.io.IOException {
textArea.append(""+(char) (b & 0xFF)); // on récupère les 8 bits de droite
}
public JTextArea getJTextArea() {
return textArea;
}
}
import java.awt.*;
import java.io.*;
import javax.swing.*;
public class Cadre1 extends JFrame {
JTextArea jTextArea1;
static OutJTextArea outJTextArea = new OutJTextArea();
public Cadre1() {
jTextArea1 = outJTextArea.getJTextArea();
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Cadre1 cadre1 = new Cadre1();
cadre1.setBounds(10,10,300,200);
cadre1.setVisible(true);
cadre1.setDefaultCloseOperation(cadre1.EXIT_ON_CLOSE);
PrintStream out = new PrintStream(outJTextArea);
System.setOut(out);
System.out.println("essai de texte\n2ème ligne");
System.out.println(true);
System.out.println(new char[] {'a','z','e','r','t','y'});
}
private void jbInit() throws Exception {
this.getContentPane().add(jTextArea1, BorderLayout.CENTER);
}
}
A+
DOBELIOU