-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfile_edit.java
More file actions
115 lines (90 loc) · 3.42 KB
/
Copy pathProfile_edit.java
File metadata and controls
115 lines (90 loc) · 3.42 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import java.sql.*;
import java.util.Arrays;
import java.io.IOException;
import java.net.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Profile_edit extends JFrame{
String filePath;
String fileName;
Profile_edit(String userid){
setTitle("Profile Edit");
setSize(500,700);
JLabel imageL = new JLabel("Profile image",SwingConstants.CENTER);
imageL.setBounds(200,70,100,30);
add(imageL);
JButton imageB = new JButton("Select Image");
imageB.setBounds(100,120,300,30);
add(imageB);
JLabel nameL = new JLabel("Name: ");
nameL.setBounds(100,200,100,30);
add(nameL);
JTextField nameText = new JTextField(15);
nameText.setBounds(200,200,200,30);
add(nameText);
JLabel stateL = new JLabel("State message: ");
stateL.setBounds(100,300,100,30);
add(stateL);
JTextField stateText = new JTextField(15);
stateText.setBounds(200,300,200,230);
add(stateText);
JButton editB = new JButton("Edit");
editB.setBounds(200,570,100,30);
add(editB);
setLayout(null);
setVisible(true);
imageB.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
Select_image a = new Select_image(userid);
filePath = a.getFilePath();
fileName = a.getFileName();
new Select_Image2(fileName);
setVisible(false);
}
});
Select_Image2 b = new Select_Image2();
fileName = b.getFileName();
String Name = nameText.getText();
String State = stateText.getText();
editB.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (Name == null || State == null) {
JOptionPane.showMessageDialog(null, "Please enter all values!");
} else {
JOptionPane.showMessageDialog(null, "Modified!");
}
}
});
editB.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
try{
DatagramSocket ds = new DatagramSocket();
InetAddress ia = InetAddress.getByName("localhost");
byte[] bf = Name.getBytes();
DatagramPacket dp = new DatagramPacket(bf, bf.length, ia, 9998);
ds.send(dp);
Arrays.fill(bf,(byte)0);
bf = State.getBytes();
dp = new DatagramPacket(bf, bf.length, ia, 9999);
ds.send(dp);
Arrays.fill(bf,(byte)0);
bf = fileName.getBytes();
dp = new DatagramPacket(bf, bf.length, ia, 9998);
ds.send(dp);
Arrays.fill(bf,(byte)0);
bf = userid.getBytes();
dp = new DatagramPacket(bf, bf.length, ia, 9998);
ds.send(dp);
}catch (Exception ex) {
ex.printStackTrace();
}
new Profile(userid);
setVisible(false);
}
});
}
}