Fix NPE in ChatRoom

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@4946 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2006-08-16 22:38:10 +00:00
committed by derek
parent a01d17d6f0
commit 37d657ce06
4 changed files with 56 additions and 23 deletions

View File

@ -54,6 +54,7 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
@ -179,6 +180,19 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
}
});
KeyStroke appleStroke = KeyStroke.getKeyStroke(Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), 0);
String appleString = org.jivesoftware.spark.util.StringUtils.keyStroke2String(appleStroke);
// Handle Apple Key W
this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(appleString + "w"), "appleStroke");
this.getActionMap().put("appleStroke", new AbstractAction("appleStroke") {
public void actionPerformed(ActionEvent evt) {
closeActiveRoom();
}
});
}
@ -1213,6 +1227,10 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
for (ChatRoom chatRoom : getStaleChatRooms()) {
// Turn tab gray
int index = indexOfComponent(chatRoom);
if (index == -1) {
return;
}
SparkTab tab = getTabAt(index);
final JLabel titleLabel = tab.getTitleLabel();