Results 1 to 3 of 3

Thread: [RESOLVED] copy console

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Resolved [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.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    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
  •  



Click Here to Expand Forum to Full Width