KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Alert


1
2 /** Alerts on certain events such as new messages being recieved.
3 * Configured thru user preferences.*/

4 public final class Alert{
5     
6     private static Sound sound=new Sound();
7     
8     public static void online(){
9         if(WhisperIM.UserPref.getProperty("alert_online").equals("true")){
10             if(WhisperIM.MainWindow.getExtendedState()==java.awt.Frame.ICONIFIED){
11                 WhisperIM.MainWindow.setExtendedState(java.awt.Frame.NORMAL);
12                 WhisperIM.MainWindow.toFront();
13             }
14             WhisperIM.MainWindow.requestFocus();
15         }
16         sound.playOnlineSound();
17     }
18     
19     public static void newMessage(){
20         if(WhisperIM.UserPref.getProperty("alert_new_message").equals("true")){
21             if(!WhisperIM.MainWindow.isActive()){
22                 WhisperIM.MainWindow.chatPane.setSelectedIndex(WhisperIM.MainWindow.chatPane.getTabCount()-1);
23             }
24             if(WhisperIM.MainWindow.getExtendedState()==java.awt.Frame.ICONIFIED){
25                 WhisperIM.MainWindow.setExtendedState(java.awt.Frame.NORMAL);
26                 WhisperIM.MainWindow.toFront();
27             }
28             WhisperIM.MainWindow.requestFocus();
29         }
30         sound.playNewMessageSound();
31     }
32     
33     public static void newChat(){
34         if(WhisperIM.UserPref.getProperty("alert_new_chat").equals("true")){
35             if(!WhisperIM.MainWindow.isActive()){
36                 WhisperIM.MainWindow.chatPane.setSelectedIndex(WhisperIM.MainWindow.chatPane.getTabCount()-1);
37             }
38             if(WhisperIM.MainWindow.getExtendedState()==java.awt.Frame.ICONIFIED){
39                 WhisperIM.MainWindow.setExtendedState(java.awt.Frame.NORMAL);
40                 WhisperIM.MainWindow.toFront();
41             }
42             WhisperIM.MainWindow.requestFocus();
43         }
44         sound.playNewChatSound();
45     }
46 }
Popular Tags