|
-
Jul 26th, 2009, 10:18 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] copy console
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...
Last edited by Justa Lol; Jul 26th, 2009 at 10:24 PM.
-
Jul 28th, 2009, 11:56 AM
#2
Re: copy console
Something like this should do the trick
Code:
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);
}
}
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 28th, 2009, 12:18 PM
#3
Thread Starter
Fanatic Member
Re: copy console
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|