| 1 28 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 64 public JExtendedPopupWindow( String strTitle, String strMessage, Icon messageIcon ) { 65 66 super(); 67 init( strTitle, strMessage, messageIcon ); 68 } 69 70 77 public JExtendedPopupWindow( Window parent, String strTitle, String strMessage, Icon messageIcon ) { 78 79 super( parent ); 80 init( strTitle, strMessage, messageIcon ); 81 } 82 83 87 public void setBackgroundIcon( Icon icon ) { 88 89 messageLabel.setIcon( icon ); 90 } 91 92 95 public Icon getBackgroundIcon() { 96 97 return messageLabel.getIcon(); 98 } 99 100 106 private void init( String strTitle, String 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 | Popular Tags |