Created
September 25, 2015 02:44
-
-
Save AnEmortalKid/df745bc5ce04360d7a9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Steve { | |
String input; | |
String[] steve = { "you", "can", "start", "by" }; | |
JFrame frame; | |
JTextField textField; | |
public Steve() { | |
frame = new JFrame(); | |
textField = new JTextField(); | |
// we set the columns to 20 at least so we can see something | |
textField.setColumns(20); | |
// we use this nice panel to put everything in its center | |
JPanel myPanel = new JPanel(); | |
myPanel.add(textField, BorderLayout.CENTER); | |
frame.add(myPanel, BorderLayout.CENTER); | |
frame.setSize(300, 300); | |
frame.setVisible(true); | |
// you gotta call speech for it to ask | |
speech1(); | |
} | |
public void speech1() { | |
for (String say : steve) { | |
input = JOptionPane.showInputDialog("Complete Neil's phrase"); | |
if (input.equals(say)) { | |
String previousText = textField.getText(); | |
textField.setText(previousText + " " + input); | |
} | |
else { | |
JOptionPane.showMessageDialog(null, "Incorrect, you typed " + input); | |
break; | |
} | |
} | |
} | |
public static void main(String[] args) { | |
new Steve(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment