1 25 26 package net.yagga.miniinstaller.gui; 27 28 import net.yagga.util.*; 29 import java.awt.*; 30 import javax.swing.*; 31 32 49 public class WritePanel extends JPanel implements InstallPanel{ 50 BorderLayout borderLayout1 = new BorderLayout(); 51 JTextArea taMsg=new JTextArea(); 52 JLabel lbImg = new JLabel(); 53 JLabel lbTitle = new JLabel(); 54 55 public static final int ICON_ALERT=1; 56 57 String title=null; 58 String text=null; 59 Icon img=null; 60 boolean splashPanel=false; 62 63 67 public WritePanel(String msg, int alertIcon) { 68 this.text=msg; 69 title=""; 70 switch(alertIcon){ 71 case ICON_ALERT: 72 title="ALERT!"; 73 img=ResourceMgr.retrieveImageIcon("img/alert.gif"); 74 break; 75 } 76 try { 77 jbInit(); 78 } 79 catch (Exception ex) { 80 ex.printStackTrace(); 81 } 82 } 83 87 public WritePanel(String msg, String imgFile) { 88 splashPanel=true; 89 this.title=msg; 90 if(imgFile!=null) 91 img=ResourceMgr.retrieveImageIcon(imgFile); 92 try { 93 jbInit(); 94 } 95 catch (Exception ex) { 96 ex.printStackTrace(); 97 } 98 } 99 100 105 public WritePanel(String title, String text, String imgFile) { 106 splashPanel=true; 107 this.title=title; 108 this.text=text; 109 if(imgFile!=null) 110 img=ResourceMgr.retrieveImageIcon(imgFile); 111 try { 112 jbInit(); 113 } 114 catch (Exception ex) { 115 ex.printStackTrace(); 116 } 117 } 118 119 void jbInit() throws Exception { 120 if(text!=null && text.trim().equals("") ) 121 text=null; 122 123 this.setPreferredSize(InstallFrame.panelDim); 124 borderLayout1.preferredLayoutSize(this); 125 this.setLayout(borderLayout1); 126 if(img!=null && title==null && text==null){ 128 lbImg.setIcon(img); 129 lbImg.setBackground(SystemColor.control); 130 this.add(lbImg, BorderLayout.CENTER); 131 } 133 else if(img==null && title!=null && text==null){ 134 taMsg.setText(title); 135 taMsg.setEditable(false); 136 taMsg.setOpaque(false); 137 taMsg.setWrapStyleWord(true); 138 taMsg.setLineWrap(true); 139 taMsg.setFont(GuiProperties.textFont); 140 this.add(taMsg, BorderLayout.CENTER); 141 } 143 else if(text==null && img!=null && title!=null){ 144 lbImg.setIcon(img); 145 lbImg.setBackground(InstallFrame.BK_COL); 146 lbImg.setHorizontalAlignment(SwingConstants.CENTER); 147 lbTitle.setText(title); 148 lbTitle.setHorizontalAlignment(SwingConstants.LEFT); 149 lbTitle.setAlignmentY(0.0f); 150 lbTitle.setFont(GuiProperties.smallTitleFont); 151 if(splashPanel){ 152 this.add(lbImg, BorderLayout.CENTER); 154 if(!title.trim().equals("")) 155 this.add(lbTitle, BorderLayout.NORTH); 156 } 157 else{ 158 this.add(lbImg, BorderLayout.WEST); 159 if(!title.trim().equals("")) 160 this.add(lbTitle, BorderLayout.CENTER); 161 } 162 } 163 else{ 164 if(img!=null){ 165 lbImg.setIcon(img); 166 lbImg.setBackground(SystemColor.control); 167 this.add(lbImg, BorderLayout.WEST); 168 } 169 taMsg.setText(text); 170 taMsg.setEditable(false); 171 taMsg.setOpaque(false); 172 taMsg.setWrapStyleWord(true); 173 taMsg.setLineWrap(true); 174 175 lbTitle.setText(title); 176 taMsg.setFont(GuiProperties.textFont); 177 lbTitle.setFont(GuiProperties.smallTitleFont); 178 lbTitle.setHorizontalAlignment(SwingConstants.LEFT); 179 lbTitle.setAlignmentY(0.0f); 180 this.add(lbTitle, BorderLayout.NORTH); 181 this.add(taMsg, BorderLayout.CENTER); 182 } 183 184 lbTitle.setFont(GuiProperties.smallTitleFont); 185 if(splashPanel){ 186 lbTitle.setHorizontalAlignment(SwingConstants.CENTER); 188 } 189 refresh(); 190 } 191 192 public void refresh(){ 193 this.setBackground(InstallFrame.BK_COL); 194 taMsg.setForeground(InstallFrame.FG_COL); 195 this.lbTitle.setForeground(InstallFrame.TIT_COL); 196 this.taMsg.setForeground(InstallFrame.FG_COL); 197 setMinimumSize(InstallFrame.panelDim); 198 setPreferredSize(InstallFrame.panelDim); 199 setMaximumSize(InstallFrame.panelDim); 200 this.validate(); 201 } 202 203 } | Popular Tags |