Input and Output in JTextFields and JTextAreas - Interactive Fiction
Code Java:
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JOptionPane;
public class eventtuna extends JFrame {
private JTextArea outputitem;
private JTextField inputitem;
public eventtuna(){
super("한글");
setLayout(new FlowLayout());
outputitem = new JTextArea("", 20, 40);
outputitem.getScrollableTracksViewpo…
outputitem.setEditable(false);
add(outputitem);
inputitem = new JTextField(10);
add(inputitem);
thehandler handler = new thehandler();
inputitem.addActionListener(handler)…
}
public class thehandler implements ActionListener{
public void actionPerformed(ActionEvent eventvar){
String stringvar = "";
if(eventvar.getSource()==inputitem)
stringvar = String.format("%s", eventvar.getActionCommand());
outputitem.setText(stringvar);
}
}
}
This all works fine, and what it does is allow you to input text in the JTextField that is ouptut in the JTextArea. The problem is, I want to beable to input text, have it output in the textarea, and then have it let you input text again and have it output on the next line down in the textarea. I need to to beable to keep doing this as well to beable to scroll as the textarea fills up.
Please help,
Thanks
Re: Input and Output in JTextFields and JTextAreas - Interactive Fiction
And where are you stuck? What's your actual question?