This repository was archived by the owner on Jul 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTakeinputfor1user.java
More file actions
79 lines (75 loc) · 2.49 KB
/
Copy pathTakeinputfor1user.java
File metadata and controls
79 lines (75 loc) · 2.49 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.company;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Takeinputfor1user {
private JFrame frame = new JFrame();
private JPanel panel = new JPanel();
private JLabel label1 = new JLabel();
private JTextField name1 = new JTextField(20);
private JButton button = new JButton("Submit");
GameBoardforUservsCpuGui game;
UservsAI game1;
String s;
Takeinputfor1user()
{
label1.setText("Name 1 : ");
panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
panel.setBackground(Color.WHITE);
panel.add(label1);
panel.add(name1);
panel.add(button);
frame.add(panel);
frame.pack();
frame.getContentPane().setBackground(Color.DARK_GRAY);
frame.setVisible(true);
init();
}
Takeinputfor1user(int s)
{
label1.setText("Name 1 : ");
panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
panel.setBackground(Color.WHITE);
panel.add(label1);
panel.add(name1);
panel.add(button);
frame.add(panel);
frame.pack();
frame.getContentPane().setBackground(Color.DARK_GRAY);
frame.setVisible(true);
init1();
}
private void init1() {
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String s = name1.getText();
if(s.isEmpty())
{
JOptionPane.showMessageDialog(null,"Name is Empty");
Takeinputfor1user takeinputgui = new Takeinputfor1user(5);
}
frame.dispose();
if((!s.isEmpty()))
game1 = new UservsAI(s);
}
});
}
private void init() {
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String s = name1.getText();
if(s.isEmpty())
{
JOptionPane.showMessageDialog(null,"Name is Empty");
Takeinputfor1user takeinputgui = new Takeinputfor1user();
}
frame.dispose();
if((!s.isEmpty()))
game = new GameBoardforUservsCpuGui(s);
}
});
}
}