📄 message.java
字号:
package jsm;
import java.net.InetAddress;
import java.net.UnknownHostException;
//以后添加其他格式的文件
public class Message {
// 消息不能带冗余的内容
InetAddress destination;
String friendName;
byte[] ip;
String sms;
public Message() {
sms = "localhost";
friendName = Controler.myName;
try {
destination = InetAddress.getByName(null);
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
public Message(String sms, byte[] ip) {
friendName = "friendName";
this.sms = sms;
this.ip = ip;
try {
destination = InetAddress.getByAddress(ip);
} catch (UnknownHostException e) {
// 弹出对话框
e.printStackTrace();
}
}
public Message(String sms, String name) {
//this.ms = ms;
this.friendName = name;
this.sms = sms;
}
public Message(String name, String sms, InetAddress destination) {
this.friendName = name;
this.sms = sms;
this.destination = destination;
}
public final InetAddress getDestination() {
return destination;
}
public final String getFriendName() {
return friendName;
}
public final String getSms() {
return sms;
}
public void setDestination(byte[] ip) {
try {
destination = InetAddress.getByAddress(ip);
} catch (UnknownHostException e) {
//会在用户输入时就要验证
e.printStackTrace();
}
}
public final void setDestination(InetAddress destination) {
this.destination = destination;
}
public final void setFriendName(String name) {
this.friendName = name;
}
public final void setSms(String sms) {
this.sms = sms;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -