import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.WindowConstants;
class DD {
public static void main(String[] args){
JFrame myFrame = new JFrame("#########");
myFrame.setSize(640,480);
myFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
myFrame.setVisible(true);
JTextArea textArea = new JTextArea();
myFrame.add(textArea);
new JTextArea();
textArea.setEditable(false);
//System objects
Scanner in = new Scanner(System.in);
boolean running = true;
textArea.append("\t\n########################################");
textArea.append("\t\n>#############");
textArea.append("\t\n>Th#############11!");
textArea.append("\t\n>Typ#############enture!");
textArea.append("\t\n########################################");
String input = in.nextLine();
if(input.equals("start")){
{ ///beginning of story.
if(running)
textArea.append("\t\nYo#############.");
textArea.append("\t\n#############");
textArea.append("\t\n1.#############t.");
textArea.append("\t\n2.G#############t.");
String input1 = in.nextLine();
if(input1.equals("1")){
textArea.append("\n>Y#############");
textArea.append("\n>#############");
textArea.append("\n>A#############");
textArea.append("\n>1.#############");
textArea.append("\n>2.#############");
if(input.equals("1")){
textArea.append("\n>#############");
textArea.append("\n>#############");
textArea.append("\n>Ga#############d.");
}
if(input.equals("2")){
textArea.append("\n>#############");
textArea.append("\n>#############");
textArea.append("\n>Y#############ars");
textArea.append("\n>Y#############");
}
}
else if(input1.equals("2")){
textArea.append("\n>Y#############.");
textArea.append("\n>Y#############.");
}
}
}
}
}
This is my text adventure game, i'm stuck on how to get users input. i have read about 'action listener' i don't know how to use it, but i really want the input to be entered like its in a console or terminal/cmd like program. the user just needs to enter 1, 2 or 3 to preform an action.