示例#1
0
 public void newMessage(TalkPack tp) {
   String from = cm.NameMap.get(tp.getFrom());
   String content = tp.getContent();
   if (talkLog.get(tp.getFrom()) != null) {
     talkLog.get(tp.getFrom()).append(from + ":\n" + content + "\n");
     jTextArea1.setText(talkLog.get(tp.getFrom()).toString());
   } else {
     talkLog.put(tp.getFrom(), new StringBuffer());
     talkLog.get(tp.getFrom()).append(from + ":\n" + content + "\n");
     jTextArea1.setText(talkLog.get(tp.getFrom()).toString());
   }
   jTextArea1.repaint();
 }
示例#2
0
 public Component getListCellRendererComponent(
     JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   if (value != null) {
     Integer num = (Integer) value;
     setText(cm.NameMap.get(num));
     setIcon(new ImageIcon(cm.IconMap.get(num)));
   }
   if (isSelected) {
     setBackground(list.getSelectionBackground());
     setForeground(list.getSelectionForeground());
   } else {
     // 设置选取与取消选取的前景与背景颜色.
     setBackground(list.getBackground());
     setForeground(list.getForeground());
   }
   return this;
 }