-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton_Handler.java
More file actions
107 lines (46 loc) · 1.67 KB
/
Button_Handler.java
File metadata and controls
107 lines (46 loc) · 1.67 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
/**
* Created by m on 18.09.2017.
*/
public class Button_Handler implements ActionListener{
public static JButton upload;
JButton b;
UserP user;
Button_Handler(JButton b){
this.b = b;
}
@Override
public void actionPerformed(ActionEvent actionEvent) {
if (b.getText().equals("Upload")) {
UserP.user.file_path =UploaderGUI.jTextField3.getText();
UserP.user.IP_address = UploaderGUI.jTextField1.getText();
try(ObjectOutputStream objOS = new ObjectOutputStream((new FileOutputStream(Net.path)))){
objOS.writeObject(UserP.user);
}
catch(IOException er){
System.out.println("хуюшки с cериализацией");
}
UploaderGUI.jTextArea1.setText("Upload\r\n");
b.setEnabled(false);
Net.host=UserP.user.IP_address;
Net.file_name=UserP.user.file_path;
new Http_client(Net.port);
upload = b;
}
if (b.getText().equals("Browse")) {
JFileChooser fch = new JFileChooser();
fch.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
fch.showDialog( null, "Open");
File file = fch.getSelectedFile();
String file_name = file.getPath();
UploaderGUI.jTextField3.setText(file_name);
}
if (b.getText().equals("Stop")) {
UploaderGUI.uploaderGUI.dispose();
System.out.println("Stop");
}
}
}