Ive been thinking about my other issue and googling and came up with this psuedocode:
import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Scanner; import javax.swing.*; public class InputOutput extends JFrame{ JPanel OUTER; static JTextArea INNER; JTextField INPUT; JButton ENTER; static Scanner in; InputOutput(){ setBounds(0,0,415,420); OUTER = new JPanel(); OUTER.setLayout(null); INPUT = new JTextField(); INPUT.setBounds(10,320,380,20); INNER = new JTextArea(); INNER.setBounds(10,10,380,300); ENTER = new JButton("ENTER"); ENTER.setBounds(10,350,380,25); OUTER.add(ENTER); OUTER.add(INNER); OUTER.add(INPUT); add(OUTER); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { in = new Scanner(System.in); new InputOutput(); } public class InputListener implements ActionListener{ public void actionPerformed(ActionEvent e) { String a = INPUT.getText(); //somehow pass string a to system.in INNER.append(in.nextLine()); } } }
The important part is the button listener i just put it all in there so it could be compiled and you knew what everything was. I figure if i can figure out how to pass that text to System.in it would trigger the scanner like it does when you hit enter after typing it into eclipse?!? i don't know though.
Thanks for the help. if found what i thought was a good step in the right direction but i couldn't quite figure out what it was doing as it didn't seem like it was doing a whole lot except changing colors.
Answer to a similar question by user Janusch
/*init in public ConsolePanel()*/ System.setIn(new MyInPrintStream()); System.setErr(new MyErrPrintStream()); /*impementation*/ class MyInPrintStream implements PrintStream{ Color col; MyInPrintStream(){col=Color.BLACK;} /*Implement PrintStream and send all input to consoleTextArea*/ } class MyErrPrintStream extends MyInPrintStream implements PrintStream{ MyInPrintStream(){col=Color.RED;} } Janusch .