-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetting.java
More file actions
192 lines (159 loc) · 5.36 KB
/
Setting.java
File metadata and controls
192 lines (159 loc) · 5.36 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package network_term;
import java.awt.*;
import javax.swing.*;
import java.sql.*;
import java.util.ArrayList;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.Scanner;
public class Setting extends JFrame implements ActionListener{
private JTextField input1,input2,input3,input4;
String driver = "com.mysql.cj.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/user";
String id = "root";
String pwd = "1234";
Connection con = null;
String[] name=new String[50];
String [] userid=new String[50];
String [] password=new String[50];
String [] introduce=new String[50];
String [] email=new String[50];
String [] phonenum=new String[50];
int [] onOff= new int[50];
int [] user_id=new int[50];
int [] friend = new int [50];
Setting(){
//데베 연결 -->DTO/DAO로 변경할 예정
try {
System.out.println("networkDB 연결중");
Class.forName(driver);
con = DriverManager.getConnection(url, id, pwd);
System.out.println("드라이버 로딩 성공");
} catch (Exception e) {
System.out.println("드라이버 로딩 실패 ");
try {
con.close();
} catch (SQLException e1) {
}
}
//데베 데이터 가져오기
//유저 정보만 !!!!!!! 배열도 필요 XXXXXXXXXXXXX
String sql = "SELECT * FROM member";
PreparedStatement pstmt = null;
ResultSet rs = null;
int i=0;
try {
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
name[i] = rs.getString("name");
userid[i] = rs.getString("id");
password[i] = rs.getString("password");
onOff[i] = rs.getInt("on/off");
introduce[i] = rs.getString("introduce");
user_id[i]= rs.getInt("user_id");
email[i]= rs.getString("email");
phonenum[i]= rs.getString("phonenum");
friend[i]= rs.getInt("friend");
i++;
}
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
try {
pstmt.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
setSize(500, 460);
setTitle("Setting");
setLocationRelativeTo(null);
//getContentPane().setBackground(Color.WHITE);
setLayout(new FlowLayout());
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
dispose();
}
});
JPanel setPanel = new JPanel();
setPanel.setBackground(Color.WHITE);
setPanel.setPreferredSize(new Dimension(500, 460));
setPanel.setLayout(null);
//프로필
ImageIcon profile= new ImageIcon("C:\\Users\\82102\\eclipse-workspace\\network_term\\src\\network_img\\user_default.png");
Image profile_png = profile.getImage(); //ImageIcon을 Image로 변환.
Image profile_png2 = profile_png.getScaledInstance(120, 120, java.awt.Image.SCALE_SMOOTH);
ImageIcon pf = new ImageIcon(profile_png2); //Image로 ImageIcon 생성
JButton profile_button=new JButton(pf);
profile_button.setBorderPainted(false);
profile_button.setContentAreaFilled(false);
profile_button.setFocusPainted(false);
profile_button.addActionListener(this);
profile_button.setBounds(18,35,100, 100);
setPanel.add(profile_button);
//폰트
Font realfont=new Font ("나눔스퀘어",Font.PLAIN,13);
//유저 이름
JLabel label1=new JLabel("MY");
setPanel.add(label1);
label1.setFont(realfont);
label1.setBounds(130, 10, 300, 35);
input1 = new JTextField(name[0]);////유저 이름 받아와서
input1.addActionListener(this);
setPanel.add(input1);
input1.setFont(realfont);
input1.setBounds(130, 40, 300, 35);
//유저 아이디
JLabel label2=new JLabel("MY ID");
setPanel.add(label2);
label2.setFont(realfont);
label2.setBounds(130, 80, 300, 35);
input2 = new JTextField(userid[0]); //유저 아이디 받아와서
input2.addActionListener(this);
setPanel.add(input2);
input2.setFont(realfont);
input2.setBounds(130, 110, 300, 35);
// 유저 이메일
JLabel label3=new JLabel("MY EMAIL");
setPanel.add(label3);
label3.setFont(realfont);
label3.setBounds(130, 150, 300, 35);
input3 = new JTextField(email[0]); //이메일 받아와서
input3.addActionListener(this);
setPanel.add(input3);
input3.setFont(realfont);
input3.setBounds(130, 180, 300, 35);
//유저 전화번호
JLabel label4=new JLabel("MY PHONE");
setPanel.add(label4);
label4.setFont(realfont);
label4.setBounds(130, 220, 300, 35);
input4 = new JTextField(phonenum[0]); //폰넘버 받아와서
input4.addActionListener(this);
setPanel.add(input4);
input4.setFont(realfont);
input4.setBounds(130, 250, 300, 35);
add(setPanel);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
}
public static void main(String[] args) throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stub
Setting JFramest = new Setting();
JFramest.setVisible(true);
}
}