-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServerThread.java
34 lines (33 loc) · 1.08 KB
/
ServerThread.java
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
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class ServerThread extends Thread implements ActionListener{
public ReverseText reverse;
public CapitalizeText capitalize;
public JTextField textBox;
public String text;
public void run(JTextField textBox, String text, JButton capitalizeText, JButton reverseText, JButton displayText){
this.textBox = textBox;
this.text = text;
reverse = new ReverseText(text);
capitalize = new CapitalizeText(text);
capitalizeText.addActionListener(this);
capitalizeText.setActionCommand("capitalize");
reverseText.addActionListener(this);
reverseText.setActionCommand("reverse");
displayText.addActionListener(this);
displayText.setActionCommand("display");
}
@Override
public void actionPerformed(ActionEvent e) {
if ("capitalize".equals(e.getActionCommand())){
textBox.setText(capitalize.returnText());
}
if ("reverse".equals(e.getActionCommand())){
textBox.setText(reverse.returnText());
}
if ("display".equals(e.getActionCommand())){
textBox.setText(text);
}
}
}