All pastes #369152 Raw Edit

Stuff

public java v1 · immutable
#369152 ·published 2007-02-23 16:37 UTC
rendered paste body
public void chatRequest(final ChatSession session) {        try {            SwingUtilities.invokeAndWait( new Runnable() {               public void run() {                   try {                       session.accept();                       String[] options = { "Accept", "Reject", "Ignore" };                       int selectedIndex = JOptionPane.showOptionDialog(                               null, session.remoteHandle() +                                "would like to chat.", "Chat Request from" +                               session.remoteHandle(),                               JOptionPane.YES_NO_CANCEL_OPTION,                               JOptionPane.QUESTION_MESSAGE,                               null, options, options[0] );                       switch (selectedIndex) {                       case JOptionPane.YES_OPTION:                                if (!CSChat.getChatSessionMap().containsKey(                                   session.remoteHandle())) {                               new ChatWindow(session.remoteHandle());                           } else {                               CSChat.getChatWindowMap().get(                                       session.remoteHandle()).toFront();                           }                           break;                       case JOptionPane.NO_OPTION:                           session.close();                           break;                       case JOptionPane.CANCEL_OPTION:                           CSChat.getServer().setEnabled(false);                           break;                       }                   }                   catch (ChatException ce) {                       System.err.println("Error: Could not chat with"+                           "user "+session.remoteHandle());                   }               }            });        } catch (InterruptedException e) {            System.err.println(e.getMessage());        } catch (InvocationTargetException e) {            System.err.println(e.getMessage());        }    }