KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > zirc > gui > PrivateFrame


1 package zirc.gui ;
2
3 import java.awt.event.* ;
4 import javax.swing.event.* ;
5 import zirc.base.* ;
6 import zirc.msg.* ;
7 import javax.swing.* ;
8
9 //zIrc, irc client.
10
// Copyright (C) 2004 CoolBytes(Stephane claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com
11
//
12
// This program is free software; you can redistribute it and/or
13
// modify it under the terms of the GNU General Public License
14
// as published by the Free Software Foundation; either version 2
15
// of the License, or (at your option) any later version.
16
//
17
// This program is distributed in the hope that it will be useful,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
// GNU General Public License for more details.
21

22 /**
23  * <p>Title: PrivateFrame</p>
24  * <p>Description: la frame des message prives</p>
25  * <p>Copyright: Copyright (c) 2004</p>
26  * <p>Company: CoolBytes(Stephane Claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com</p>
27  * @version 1.0
28  */

29
30 public class PrivateFrame extends AbstractChatFrame
31 {
32   private final ImageIcon privIMG = new ImageIcon("fichiers/images/privateIcon.png") ;
33   private String JavaDoc correspondant ;
34
35   public PrivateFrame(IRCconnexion _IRCchat, String JavaDoc _correspondant)
36   {
37     super(_IRCchat) ;
38     this.setFrameIcon(privIMG);
39     correspondant = _correspondant ;
40   }
41
42   void jTextField1_actionPerformed(ActionEvent e)
43   {
44
45     String JavaDoc txt = jTextField1.getText() ;
46
47     if (txt.length() > 0)
48     {
49
50       if (txt.charAt(0) == '/')
51       {
52         //envoyer une commande
53
IRCchat.sendCommand(txt.substring(1)) ;
54       }
55       else
56       {
57         //envoyer la commande
58
String JavaDoc send = "PRIVMSG " + correspondant + " :" + txt ;
59         IRCchat.sendCommand(send) ;
60
61         //displayer le message envoyé
62
MSGprivMsg msg = new MSGprivMsg(IRCchat, ":" + IRCchat.GetUser_nickName() + "!", correspondant, send) ;
63         msg.reagit() ;
64         msg.affiche() ;
65       }
66     }
67
68     jTextField1.setText("") ;
69
70   }
71
72   void this_internalFrameClosed(InternalFrameEvent e)
73   {
74     super.this_internalFrameClosed(e) ;
75     destroy() ;
76   }
77
78   public void destroy()
79   {
80
81     //on ferme la connexion avec le chan si ca a pas deja été fait
82
IRCchat.removePrivate(this) ;
83
84     try
85     {
86       setClosed(true) ;
87     }
88     catch (java.beans.PropertyVetoException JavaDoc e)
89     {
90       System.out.println("propertyVeto...") ;
91     }
92   }
93
94   public String JavaDoc getCorrespondant()
95   {
96     return correspondant ;
97   }
98
99   public void setCorrespondant(String JavaDoc _name)
100   {
101     this.setCorrespondant(_name) ;
102     setTitle(_name) ;
103   }
104 }
105
Popular Tags