📄 modifyframe.java
字号:
package com.client ;
import javax.swing.* ;
import java.awt.*;
import java.awt.event.*;
import java.util.EventListener;
import com.server.DataBase ;
import java.sql.* ;
import java.net.* ;
import java.io.* ;
public class ModifyFrame extends JFrame implements ActionListener {
private Socket s ;
private String u ;
private String username ;
private String email ;
private String author ;
JLabel l_username2 = new JLabel() ;
JTextField t_email = new JTextField() ;
JTextField t_author = new JTextField();
public void setSocket(Socket scoket , String username){
this.s = scoket ;
this.u= username;
}
public void setInfo(String value1 , String value2 , String value3){
this.username = value1 ;
this.email = value2 ;
this.author = value3 ;
}
public void init(){
l_username2.setText(username) ;
t_email.setText(email) ;
t_author.setText(author) ;
}
ModifyFrame(){
this.setSize(400 , 200) ;
// this.setResizable(false) ;
JLabel l_username = new JLabel("用户名:") ;
JLabel l_email = new JLabel("邮箱:") ;
JLabel l_author = new JLabel("身份:") ;
JPanel p_center = new JPanel() ;
p_center.setLayout(new GridLayout(3,2)) ;
p_center.add(l_username) ;
p_center.add(l_username2) ;
p_center.add(l_email) ;
p_center.add(t_email) ;
p_center.add(l_author) ;
p_center.add(t_author) ;
JButton b_modify = new JButton("修改") ;
JButton b_remove = new JButton("删除") ;
JButton b_search = new JButton("查找") ;
b_modify.addActionListener(this) ;
b_remove.addActionListener(this) ;
b_search.addActionListener(this) ;
JPanel p_south = new JPanel() ;
p_south.setLayout(new FlowLayout()) ;
p_south.add(b_modify) ;
p_south.add(b_remove) ;
p_south.add(b_search) ;
this.setLayout(new BorderLayout()) ;
this.add(p_center , BorderLayout.CENTER) ;
this.add(p_south , BorderLayout.SOUTH) ;
this.setVisible(true) ;
}
public void actionPerformed(ActionEvent e) {
try {
if(e.getActionCommand().equals("修改")){
OutputStream os = s.getOutputStream() ;
OutputStreamWriter osw = new OutputStreamWriter(os) ;
PrintWriter pw = new PrintWriter(osw , true) ;
pw.println("modify"+"%"+u+"%"+l_username2.getText()+"%"+t_email.getText()+"%"+t_author.getText()) ;
}
if(e.getActionCommand().equals("删除")){
OutputStream os = s.getOutputStream() ;
OutputStreamWriter osw = new OutputStreamWriter(os) ;
PrintWriter pw = new PrintWriter(osw , true) ;
pw.println("remove"+"%"+u+"%"+l_username2.getText()) ;
}
if(e.getActionCommand().equals("查找")){
SearchFrame sf = new SearchFrame() ;
sf.setSocket(s , u) ;
this.setVisible(false) ;
}
}
catch (Exception ex) {
ex.printStackTrace() ;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -