Click to See Complete Forum and Search --> : [RESOLVED] copy console
Justa Lol
Jul 26th, 2009, 10:18 PM
how can i copy/view the console into a textArea in a gui/JFrame?
EDIT: more information
i want to copy/view the console of the program thats running into the gui or remove the console and make it show in a gui/Jframe...
ComputerJy
Jul 28th, 2009, 11:56 AM
Something like this should do the trick
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class Test {
public static void main(final String[] args) {
final JFrame frm = new JFrame();
final JTextField textField = new JTextField();
System.setOut(new PrintStream(new OutputStream() {
@Override
public void write(final int b) throws IOException {
textField.setText(textField.getText() + (char) b);
}
}));
frm.add(textField);
frm.setSize(200, 200);
System.out.println("Welcome home");
frm.setVisible(true);
}
}
Justa Lol
Jul 28th, 2009, 12:18 PM
i figured another way, so instead of copying all the console i just did textArea3.append then the text where everything i needed was so instead of taking all i just took what i needed, by coping to misc.println and add a textArea3.append instead. but thats for help anyways.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.