public String commando(String username, String channel, String text) throws RemoteException{
String[] result = text.split(" ", 3);
if(result[0].equalsIgnoreCase("/join")){
channel = result[1];
setChannel(channel);
joinChannel(username, channel);
}
else if(result[0].equalsIgnoreCase("/leave")){
channel = result[1];
setChannel(channel);
leaveChannel(username, channel);
}
else if(result[0].equalsIgnoreCase("/whisper")){
for (int x=2; x<result.length; x++)
newPrivateMessage(username, result[1], result[x]);
}
else if(result[0].equalsIgnoreCase("/exit")){
System.exit(0);
}
else{
error(brukernavn, "Wrong!");
}
return tekst;
}
我需要紅色的錯誤。此消息(「錯誤!」)發送給用戶,他寫了類似於/ dfdsfsd的信息。我在屏幕上顯示消息,但無法將其顯示爲紅色。一些想法?RMI聊天程序,需要紅色的「錯誤」信息
編輯:
干擾:
public interface ChatFront extends Remote {
void error(String to, String message) throws RemoteException;
}
public interface Klient extends Remote {
void error(String to, String message) throws RemoteException;
}
在服務器:
class ChatFrontImpl extends UnicastRemoteObject implements ChatFront {
private UserDAO b = new UserDAO();
private Hashtable<String, ArrayList<String>> chanel = new Hashtable<String, ArrayList<String>>();
private ArrayList<Klient> clients= new ArrayList<Client>();
public ChatFrontImpl() throws RemoteException {
}
public void error(String to, String message) throws RemoteException{
errorTo(to, message);
}
private void errorTo(String to, String message) throws RemoteException{
for(Client k: clients){
if(k.findName().equals(to)){
k.error(to, message);
}
}
}
我已編輯的一些名字的(使用挪威),所以這可能是一個問題的U,但該計劃的作品。唯一的問題是,我不能得到錯誤信息的紅色
編輯2:忘記在客戶端GUI:
public class GUI extends javax.swing.JFrame {
GUILogikk gl = new GUILogikk(this);
public void error(String to, String message){
//chatFelt.setCaretColor(Color.RED);
chatFelt.append("" + message + "\n");
chatFelt.setCaretPosition(chatFelt.getText().length());
}
}
什麼是用戶界面技術? – home 2012-01-06 13:53:42
向我們展示樣式(顏色)界面的代碼,也許我們可以提供幫助。你在使用Swing,AWT,SWT,一個終端窗口嗎? – jefflunt 2012-01-06 14:38:50