MY CODE
package pack.TAgame;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class AL_Test {
public static void main(String[] args){
//JFrame
JFrame Frame = new JFrame("AL Test");
Frame.setSize(720,480);
Frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Frame.setVisible(true);
Frame.setResizable(false);
//Text Area
JTextArea textArea = new JTextArea();
textArea.setBackground(Color.BLACK);
textArea.setForeground(Color.GRAY);
JLabel jl = new JLabel();
Frame.add(textArea);
textArea.setEditable(false);
//Text Field
JTextField jt = new JTextField(50);
JPanel jp = new JPanel();
jp.add(jt);
Frame.add(jt, BorderLayout.SOUTH);
class UserInput extends JFrame implements ActionListener{
public UserInput() {
}
public void actionPerformed(ActionEvent e) {
JTextField jt = new JTextField();
JTextArea textArea = new JTextArea();
jt.addActionListener(this);
String text = jt.getText();
textArea.append("\n>What does the scouter say about his power level?");
}
}
}
}
This maybe a little like my other post...(In my code for the actionlistener
part I gave up and I might have some useless code in it)
so basically I want a JTextField
that when I type a certain command to print something into my JTextArea. (Without the use of a button (i.e. Press enter))