displaymessage.java
来自「rmi chat that connects two or more clien」· Java 代码 · 共 56 行
JAVA
56 行
import java.rmi.*;
import java.rmi.server.*;
public class DisplayMessage extends UnicastRemoteObject implements Notify {
private javax.swing.JTextArea textArea;
private String name;
public DisplayMessage(javax.swing.JTextArea ta)
throws RemoteException {
textArea = ta;
}
public void joinMessage(String name)
throws RemoteException
{
try {
textArea.append(name + " has joined\n");
}
catch(Exception e){
System.out.println("Message Failure");
e.printStackTrace();
};
}
public void sendMessage(String name, String message) throws RemoteException
{
try {
textArea.append(name + " says: " + message + "\n");
}
catch(Exception e){
System.out.println("Message Failure");
e.printStackTrace();
};
}
public void exitMessage(String name) throws RemoteException {
try {
textArea.append(name + " has left the building.\n");
}
catch(Exception e){
System.out.println("Message Failure");
};
}
//Notice this one not called remotely
public void setName(String name) throws RemoteException {
this.name = name;
}
public String getName() {
return name;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?