-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrank.java
More file actions
40 lines (39 loc) · 1.17 KB
/
Prank.java
File metadata and controls
40 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Prank extends JFrame implements ActionListener{
JButton ok;
JLabel prankLabel;
JTextField prankField;
String[] options= { "Accepted", "Declined" };
String name;
int response;
Prank(){
super("Challenge");
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane=new JPanel();
prankField= new JTextField(18);
prankLabel= new JLabel("Try to enter you're name");
int response=JOptionPane.showOptionDialog(null, "Challenge: Type you're name in the Text Box", "Challenge", 0, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
if (response==1)
System.exit(0);
ok=new JButton("Give Up");
ok.addActionListener(this);
prankField.addActionListener(this);
pane.add(prankLabel);
pane.add(prankField);
pane.add(ok);
add(pane);
pack();
prankField.setEditable(false);
setVisible(true);
}
public void actionPerformed(ActionEvent evt){
JOptionPane.showMessageDialog(null, "HAHAHAHAHAHA you lose", "You Lose", JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
public static void main(String[] args){
Prank p=new Prank();
}
}