KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > planetamessenger > mos > ui > JExtendedPopupWindow


1 /*
2     =========================================================================
3
4     This module is developed and maintained by PlanetaMessenger.org.
5     Specs, New and updated versions can be found in
6     http://www.planetamessenger.org
7     If you want contact the Team please send a email to Project Manager
8     Leidson Campos Alves Ferreira at leidson@planetamessenger.org
9
10     Copyright (C) since 2001 by PlanetaMessenger.org
11
12     This program is free software; you can redistribute it and/or modify
13     it under the terms of the GNU General Public License as published by
14     the Free Software Foundation; either version 2 of the License, or
15     (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     You should have received a copy of the GNU General Public License
23     along with this program; if not, write to the Free Software
24     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
26     =========================================================================
27 */

28 /**
29  *
30  * $Id: JExtendedPopupWindow.java,v 1.2 2007/01/29 18:15:36 popolony2k Exp $
31  * $Author: popolony2k $
32  * $Name: $
33  * $Revision: 1.2 $
34  * $State: Exp $
35  *
36  */

37
38 package org.planetamessenger.mos.ui;
39
40 import org.planetamessenger.mos.engine.*;
41 import org.planetamessenger.ui.*;
42 import javax.swing.border.*;
43 import javax.swing.*;
44 import java.awt.*;
45
46
47
48 public class JExtendedPopupWindow extends JPopupWindow {
49
50   private final int WINDOW_WIDTH = 300;
51   private final int WINDOW_HEIGHT = 200;
52   private final int DEFAULT_STRING_HEIGHT = 32;
53
54   private JLabel iconLabel = null;
55   private JLabel messageLabel = null;
56     
57
58   /**
59    * Constructor. Initializes all class data.<br>
60    * @param strTitle The window title (border title);<br>
61    * @param strMessage The window message;<br>
62    * @param messageIcon The message icon placed on left side of message;
63    */

64   public JExtendedPopupWindow( String JavaDoc strTitle, String JavaDoc strMessage, Icon messageIcon ) {
65     
66     super();
67     init( strTitle, strMessage, messageIcon );
68   }
69   
70   /**
71    * Constructor. Initializes all class data.<br>
72    * @param parent The Parent JWindow of this PopupWindow;<br>
73    * @param strTitle The window title (border title);<br>
74    * @param strMessage The window message;<br>
75    * @param messageIcon The message icon placed on left side of message;<br>
76    */

77   public JExtendedPopupWindow( Window parent, String JavaDoc strTitle, String JavaDoc strMessage, Icon messageIcon ) {
78     
79     super( parent );
80     init( strTitle, strMessage, messageIcon );
81   }
82       
83   /**
84    * Set the background image for Popup window.<br>
85    * @param icon The new backgrond icon for popup window;<br>
86    */

87   public void setBackgroundIcon( Icon icon ) {
88     
89     messageLabel.setIcon( icon );
90   }
91     
92   /**
93    * Get the background icon for popup window.<br>
94    */

95   public Icon getBackgroundIcon() {
96    
97     return messageLabel.getIcon();
98   }
99   
100   /**
101    * Init all class data.<br>
102    * @param strTitle The window title;<br>
103    * @param strMessage The window body message;<br>
104    * @param messageIcon The message icon placed on left side of message;<br>
105    */

106   private void init( String JavaDoc strTitle, String JavaDoc strMessage, Icon messageIcon ) {
107     
108     JPanel contentPane = ( JPanel ) getContentPane();
109     int nWidth = 0;
110     int nHeight = 0;
111
112
113     setBorder( new TitledBorder( strTitle ) );
114     
115     messageLabel = new JLabel( strMessage );
116     messageLabel.setFont( JSystemFonts.FONT );
117     messageLabel.setVerticalTextPosition( JLabel.CENTER );
118     messageLabel.setHorizontalAlignment( JLabel.CENTER );
119
120     contentPane.setLayout( new GridBagLayout() );
121
122     if( messageIcon != null ) {
123       JLabel label = new JLabel();
124
125       label.setIcon( messageIcon );
126       contentPane.add( label );
127     }
128     
129     contentPane.add( messageLabel );
130     
131     setSize( WINDOW_WIDTH, WINDOW_HEIGHT );
132   }
133 }
134
135 // JExtendedPopupWindow class
136
Popular Tags