ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
2211
2211
EMPFEHLEN
-
05.01.07 14:40 #1
- Registriert seit
- Jul 2003
- Beiträge
- 4
Hi,
kann das jemand kurz umreissen, wie ich sowas anstelle. Hab in Netz viele unterschiedliche, aber keine funktionierende Loesung gefunden. Ich wuerde gerne die Ausgabe von System.out in ein SWT-Text-Widget umleiten.
mfG,
thomas B.
-
05.01.07 15:00 #2
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo!
Schau mal hier:
Code java:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
package de.tutorials; import java.io.PrintStream; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; /** * <p> * TODO Description of the type * </p> * @author Thomas.Darimont */ public class SystemOutRedictionExample { /** * <p> * TODO Description of method * </p> * @param args */ public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setSize(320, 240); final Text text = new Text(shell, SWT.V_SCROLL | SWT.H_SCROLL); text.setEditable(false); shell.setText("SystemErrRedictionExample"); shell.open(); final PrintStream backupSystemOutStream = System.out; System.setOut(new PrintStream(backupSystemOutStream) { public void print(final String s) { display.asyncExec(new Runnable() { public void run() { text.append(s); text.append("\n"); } }); super.print("aaaa: " + s); } }); new Thread() { { setDaemon(true); } public void run() { while (true) { System.out.println(System.currentTimeMillis() + ": xxx"); new Exception().printStackTrace(System.out); try { Thread.sleep(2000L); } catch (InterruptedException e) { e.printStackTrace(); } } } }.start(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } }
Gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
Ähnliche Themen
-
Eclipse umleiten von System.out etc.
Von takidoso im Forum JavaAntworten: 3Letzter Beitrag: 12.08.09, 13:40 -
DragDetect auf Text-Widget [SWT]
Von Fishtaco im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 0Letzter Beitrag: 14.08.08, 11:42 -
System.err auf JTextArea umleiten
Von ZAntjeZ im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 2Letzter Beitrag: 08.10.07, 08:38 -
SWT Text-Widget: Höhenangabe wird ignoriert!!
Von Vatar im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 1Letzter Beitrag: 09.08.05, 16:32 -
Brauche dringend Hilfe bei SWT Text Widget in MultiPartEditor
Von Stonykay im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 1Letzter Beitrag: 15.11.04, 18:22





Zitieren

Login





