mirror of
https://github.com/FatttSnake/ClassroomInteraction.git
synced 2026-04-06 05:41:26 +08:00
Init student's Center,ChangePassword,Chat,MainWindow
This commit is contained in:
@@ -65,26 +65,6 @@
|
|||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
<grid id="9734" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
|
||||||
<constraints>
|
|
||||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
<border type="none"/>
|
|
||||||
<children>
|
|
||||||
<component id="47a94" class="javax.swing.JButton" binding="signInButton">
|
|
||||||
<constraints>
|
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
|
||||||
<preferred-size width="80" height="40"/>
|
|
||||||
</grid>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<text value="签到"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
</children>
|
|
||||||
</grid>
|
|
||||||
<grid id="2e1bc" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="2e1bc" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
@@ -119,17 +99,9 @@
|
|||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<font name="Microsoft YaHei" size="20" style="0"/>
|
<font name="Microsoft YaHei" size="20" style="0"/>
|
||||||
<text value="课程"/>
|
<text value="姓名"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="8648e" class="javax.swing.JTextArea" binding="textClass">
|
|
||||||
<constraints>
|
|
||||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
|
||||||
<preferred-size width="150" height="50"/>
|
|
||||||
</grid>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
</component>
|
|
||||||
<component id="ebeec" class="javax.swing.JButton" binding="connectButton">
|
<component id="ebeec" class="javax.swing.JButton" binding="connectButton">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
@@ -138,6 +110,36 @@
|
|||||||
<text value="连接"/>
|
<text value="连接"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
<component id="3e0aa" class="javax.swing.JTextField" binding="stuNameText">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="150" height="-1"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<editable value="false"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
<grid id="7594c" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="3824" class="javax.swing.JButton" binding="signInButton">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="80" height="40"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="签到"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.cfive.classroom.student;
|
|||||||
|
|
||||||
import com.cfive.classroom.library.database.DatabaseHelper;
|
import com.cfive.classroom.library.database.DatabaseHelper;
|
||||||
import com.cfive.classroom.library.database.bean.AttStatus;
|
import com.cfive.classroom.library.database.bean.AttStatus;
|
||||||
import com.cfive.classroom.library.database.util.DependenciesNotFoundException;
|
|
||||||
import com.cfive.classroom.library.database.util.NoConfigException;
|
import com.cfive.classroom.library.database.util.NoConfigException;
|
||||||
import com.cfive.classroom.library.net.StudentNet;
|
import com.cfive.classroom.library.net.StudentNet;
|
||||||
import com.cfive.classroom.library.net.util.MessageObject;
|
import com.cfive.classroom.library.net.util.MessageObject;
|
||||||
@@ -23,15 +22,15 @@ import java.util.Properties;
|
|||||||
|
|
||||||
public class Center {
|
public class Center {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
private static final Center center = new Center();
|
private static Center center;
|
||||||
private JButton signInButton;
|
|
||||||
private JButton raiseHandButton;
|
private JButton raiseHandButton;
|
||||||
private JButton chatButton;
|
private JButton chatButton;
|
||||||
private JPanel rootpanel;
|
private JPanel rootpanel;
|
||||||
private JButton changePasswordButton;
|
private JButton changePasswordButton;
|
||||||
private JTextArea textClass;
|
|
||||||
private JButton connectButton;
|
private JButton connectButton;
|
||||||
private JTextField stuNoText;
|
private JTextField stuNoText;
|
||||||
|
private JTextField stuNameText;
|
||||||
|
private JButton signInButton;
|
||||||
private static JFrame frame = new JFrame("Center");
|
private static JFrame frame = new JFrame("Center");
|
||||||
private StudentNet studentNet;
|
private StudentNet studentNet;
|
||||||
private String host;
|
private String host;
|
||||||
@@ -39,17 +38,22 @@ public class Center {
|
|||||||
private String signInCode;
|
private String signInCode;
|
||||||
private String stuNo;
|
private String stuNo;
|
||||||
private String stuName;
|
private String stuName;
|
||||||
|
private String getSignInCode;
|
||||||
private MessageObject messageObject;
|
private MessageObject messageObject;
|
||||||
|
|
||||||
public Center() {
|
public Center(String stuNo) {
|
||||||
|
this.stuNo = stuNo;
|
||||||
|
this.stuName = getName(stuNo);
|
||||||
|
stuNoText.setText(stuNo);
|
||||||
|
stuNameText.setText(stuName);
|
||||||
//留言
|
//留言
|
||||||
chatButton.addActionListener(new ActionListener() {
|
chatButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
LOGGER.info("chatButton.studentNet"+studentNet);
|
||||||
if (studentNet != null) {
|
if (studentNet != null) {
|
||||||
Chat chat = new Chat();
|
Chat chat = new Chat(studentNet,stuNo,stuName);
|
||||||
chat.start(stuNo, stuName, studentNet);
|
chat.start();
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null,"没有连接至教师");
|
JOptionPane.showMessageDialog(null,"没有连接至教师");
|
||||||
}
|
}
|
||||||
@@ -59,8 +63,8 @@ public class Center {
|
|||||||
changePasswordButton.addActionListener(new ActionListener() {
|
changePasswordButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
ChangePassword changePassword = new ChangePassword();
|
ChangePassword changePassword = new ChangePassword(stuNoText.getText());
|
||||||
changePassword.start(stuNoText.getText());
|
changePassword.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//连接
|
//连接
|
||||||
@@ -78,37 +82,35 @@ public class Center {
|
|||||||
try {
|
try {
|
||||||
studentNet = new StudentNet(host,port);
|
studentNet = new StudentNet(host,port);
|
||||||
JOptionPane.showMessageDialog(null, "连接成功");
|
JOptionPane.showMessageDialog(null, "连接成功");
|
||||||
|
//签到
|
||||||
|
studentNet.setOnReceiveListener(new ReceiveListener() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(MessageObject messageObject) {
|
||||||
|
if (messageObject.getMessageType() == MessageType.CheckIn) {
|
||||||
|
getSignInCode = messageObject.getCode();
|
||||||
|
LOGGER.info(messageObject.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
JOptionPane.showMessageDialog(null,"连接失败");
|
JOptionPane.showMessageDialog(null,"连接失败");
|
||||||
LOGGER.error("IOException",ex);
|
LOGGER.error("IOException",ex);
|
||||||
}
|
}
|
||||||
|
LOGGER.info("connect.studentNet"+studentNet);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//签到
|
|
||||||
signInButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
signInCode = JOptionPane.showInputDialog(null,"签到码:","签到",JOptionPane.PLAIN_MESSAGE);
|
|
||||||
studentNet.setOnReceiveListener(new ReceiveListener() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(MessageObject messageObject) {
|
|
||||||
if (messageObject.getMessageType()==MessageType.CheckIn&&messageObject.getCode().equals(signInCode)) {
|
|
||||||
// studentNet.sendMessageThread(new MessageObject(stuNo,stuName,null, null,null,AttStatus.signed,LocalDateTime.now(),null));
|
|
||||||
JOptionPane.showMessageDialog(null, "签到成功");
|
|
||||||
} else {
|
|
||||||
JOptionPane.showMessageDialog(null,"签到失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//举手
|
//举手
|
||||||
raiseHandButton.addActionListener(new ActionListener() {
|
raiseHandButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
LOGGER.info(stuNo+stuName);
|
||||||
messageObject = new MessageObject(stuNo, stuName, null, null, null, null,null,MessageType.RaiseHand);
|
messageObject = new MessageObject(stuNo, stuName, null, null, null, null,null,MessageType.RaiseHand);
|
||||||
// studentNet.sendMessageThread(messageObject);
|
studentNet.sendMessage(messageObject);
|
||||||
|
LOGGER.info(messageObject.getStuNo()+messageObject.getStuName());
|
||||||
JOptionPane.showMessageDialog(null,"你已经向老师举手");
|
JOptionPane.showMessageDialog(null,"你已经向老师举手");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -123,21 +125,33 @@ public class Center {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
signInButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (getSignInCode != null) {
|
||||||
|
signInCode = JOptionPane.showInputDialog(null, "签到码:", "签到", JOptionPane.PLAIN_MESSAGE);
|
||||||
|
LOGGER.info(getSignInCode);
|
||||||
|
if (getSignInCode.equals(signInCode)) {
|
||||||
|
studentNet.sendMessage(new MessageObject(stuNo, stuName, null, null, null, AttStatus.signed, LocalDateTime.now(), MessageType.CheckIn));
|
||||||
|
JOptionPane.showMessageDialog(null, "签到成功");
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "签到失败");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null,"无签到码");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void start(String num){
|
public void start(){
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
frame.setContentPane(center.rootpanel);
|
frame.setContentPane(rootpanel);
|
||||||
frame.setSize(600,400);
|
frame.setSize(600,400);
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
center.stuNoText.setText(num);
|
|
||||||
stuNo = String.valueOf(stuNoText.getText());
|
|
||||||
stuName = getName();
|
|
||||||
LOGGER.info("学号"+stuNo);
|
|
||||||
LOGGER.info("姓名"+stuName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@@ -150,10 +164,10 @@ public class Center {
|
|||||||
|
|
||||||
}
|
}
|
||||||
//获取学生姓名
|
//获取学生姓名
|
||||||
public String getName(){
|
public String getName(String stuNo){
|
||||||
String name = null;
|
String name = null;
|
||||||
try {
|
try {
|
||||||
name=DatabaseHelper.selectFromStudent(Long.parseLong(stuNoText.getText())).getStuName();
|
name=DatabaseHelper.selectFromStudent(Long.parseLong(stuNo)).getStuName();
|
||||||
} catch (NoConfigException e) {
|
} catch (NoConfigException e) {
|
||||||
JOptionPane.showMessageDialog(null,"没有数据库配置文件","警告",JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null,"没有数据库配置文件","警告",JOptionPane.ERROR_MESSAGE);
|
||||||
LOGGER.error("No configuration", e);
|
LOGGER.error("No configuration", e);
|
||||||
@@ -165,4 +179,5 @@ public class Center {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import java.sql.SQLException;
|
|||||||
|
|
||||||
public class ChangePassword {
|
public class ChangePassword {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
private static final ChangePassword changePassword = new ChangePassword();
|
|
||||||
|
|
||||||
private JPanel rootPanel;
|
private JPanel rootPanel;
|
||||||
private JTextField textNum;
|
private JTextField textNum;
|
||||||
private JButton cancel;
|
private JButton cancel;
|
||||||
@@ -22,10 +20,10 @@ public class ChangePassword {
|
|||||||
private JPasswordField passwordField1;
|
private JPasswordField passwordField1;
|
||||||
private JPasswordField passwordField2;
|
private JPasswordField passwordField2;
|
||||||
private static JFrame frame = new JFrame("修改密码");
|
private static JFrame frame = new JFrame("修改密码");
|
||||||
|
private String studentNo;
|
||||||
|
|
||||||
private String stuNo;
|
public ChangePassword(String stuNo) {
|
||||||
|
this.studentNo = stuNo;
|
||||||
public ChangePassword() {
|
|
||||||
confirm.addActionListener(e -> {
|
confirm.addActionListener(e -> {
|
||||||
if(check()){
|
if(check()){
|
||||||
try {
|
try {
|
||||||
@@ -57,12 +55,16 @@ public class ChangePassword {
|
|||||||
String password1,password2,num;
|
String password1,password2,num;
|
||||||
num = String.valueOf(textNum.getText());
|
num = String.valueOf(textNum.getText());
|
||||||
|
|
||||||
LOGGER.info("传入学号"+stuNo);
|
LOGGER.info("传入学号"+studentNo);
|
||||||
LOGGER.info(num);
|
LOGGER.info(num);
|
||||||
|
|
||||||
password1 = String.valueOf(passwordField1.getPassword());
|
password1 = String.valueOf(passwordField1.getPassword());
|
||||||
password2 = String.valueOf(passwordField2.getPassword());
|
password2 = String.valueOf(passwordField2.getPassword());
|
||||||
if(num.equals(stuNo)){
|
if (num == null) {
|
||||||
|
JOptionPane.showMessageDialog(null, "输入的学号为空");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if(num.equals(studentNo)){
|
||||||
if (password1.length()==0 || password2.length()==0) {
|
if (password1.length()==0 || password2.length()==0) {
|
||||||
JOptionPane.showMessageDialog(null,"输入的密码为空");
|
JOptionPane.showMessageDialog(null,"输入的密码为空");
|
||||||
return false;
|
return false;
|
||||||
@@ -76,21 +78,12 @@ public class ChangePassword {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
public void start() {
|
||||||
public void start(String stuNo) {
|
frame.setContentPane(rootPanel);
|
||||||
frame.setContentPane(changePassword.rootPanel);
|
|
||||||
frame.setSize(600,400);
|
frame.setSize(600,400);
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
changePassword.stuNo = stuNo;
|
|
||||||
LOGGER.info(changePassword.stuNo);
|
|
||||||
}
|
|
||||||
public static void main(String[] args) {
|
|
||||||
frame.setContentPane(changePassword.rootPanel);
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.setSize(600,400);
|
|
||||||
frame.setVisible(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.cfive.classroom.student;
|
package com.cfive.classroom.student;
|
||||||
|
|
||||||
import com.cfive.classroom.library.net.ReceiveThread;
|
|
||||||
import com.cfive.classroom.library.net.StudentNet;
|
import com.cfive.classroom.library.net.StudentNet;
|
||||||
import com.cfive.classroom.library.net.util.MessageObject;
|
import com.cfive.classroom.library.net.util.MessageObject;
|
||||||
import com.cfive.classroom.library.net.util.MessageType;
|
import com.cfive.classroom.library.net.util.MessageType;
|
||||||
@@ -12,29 +11,28 @@ import javax.swing.*;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class Chat {
|
public class Chat {
|
||||||
private static final Chat chat = new Chat();
|
|
||||||
private JPanel panel1;
|
private JPanel panel1;
|
||||||
private JButton sendButton;
|
private JButton sendButton;
|
||||||
private JTextArea receiveText;
|
private JTextArea receiveText;
|
||||||
private JTextArea sendText;
|
private JTextArea sendText;
|
||||||
private static JFrame frame = new JFrame("留言");
|
private static JFrame frame = new JFrame("留言");
|
||||||
private StudentNet studentNet;
|
|
||||||
private String stuNo, stuName,host;
|
|
||||||
private int port;
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
public Chat() {
|
public Chat(StudentNet studentNet,String stuNo,String stuName) {
|
||||||
|
|
||||||
//发送消息
|
//发送消息
|
||||||
sendButton.addActionListener(new ActionListener() {
|
sendButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if(String.valueOf(sendText.getText())!=null) {
|
String sendMessage = sendText.getText();
|
||||||
LOGGER.info(LocalDateTime.now());
|
if(sendMessage!=null) {
|
||||||
studentNet.sendMessageThread(new MessageObject(stuNo, stuName, null, String.valueOf(sendText.getText()) ,null,null,LocalDateTime.now(),MessageType.Chat));
|
LOGGER.info(stuNo+stuName);
|
||||||
|
receiveText.append("我:"+LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+sendMessage+"\n");
|
||||||
|
studentNet.sendMessage(new MessageObject(stuNo, stuName, null,stuName+":"+sendText.getText() ,null,null,LocalDateTime.now(),MessageType.Chat));
|
||||||
|
sendText.setText("");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
JOptionPane.showMessageDialog(null,"无发送内容","错误!",JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null,"无发送内容","错误!",JOptionPane.ERROR_MESSAGE);
|
||||||
@@ -46,18 +44,16 @@ public class Chat {
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(MessageObject messageObject) {
|
public void onReceive(MessageObject messageObject) {
|
||||||
if(messageObject.getMessageType()==MessageType.ChatToAll){
|
if(messageObject.getMessageType()==MessageType.ChatToAll){
|
||||||
receiveText.append("教师:\n"+messageObject.getMessage()+"\n");
|
receiveText.append("教师:"+LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+'\n'+messageObject.getMessage()+"\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public void start(String num, String name,StudentNet studentNet1) {
|
|
||||||
frame.setContentPane(new Chat().panel1);
|
public void start() {
|
||||||
|
frame.setContentPane(this.panel1);
|
||||||
frame.setSize(600, 400);
|
frame.setSize(600, 400);
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
chat.stuNo = num;
|
|
||||||
chat.stuName = name;
|
|
||||||
chat.studentNet = studentNet1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,11 +33,13 @@ public class MainWindow{
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if(check()){
|
if(check()){
|
||||||
LOGGER.info("new Center");
|
Center center = new Center(stuNoText.getText());
|
||||||
new Center().start(stuNoText.getText());
|
center.start();
|
||||||
LOGGER.info("center.start");
|
|
||||||
frame.dispose();
|
frame.dispose();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
JOptionPane.showMessageDialog(null,"密码错误");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user