1 15 16 18 36 package ixenon.free.install; 37 38 import java.awt.*; 39 import java.awt.event.*; 40 import java.util.*; 42 import java.io.*; 43 44 import javax.swing.*; import javax.swing.event.*; 46 import javax.swing.text.*; import javax.swing.border.*; 49 import ixenon.free.util.*; import ixenon.free.swing.*; 52 53 62 public class ProgressFrame extends JFrame 63 { 64 private JLabel label; 65 private JTextPane textPane; 66 private JProgressBar progressBarNode; 67 private JProgressBar progressBarFile; 68 69 73 public ProgressFrame( String title ) 74 { 75 super(title); 76 77 ApplicationResources appres = ApplicationResources.getInstance(); 81 82 String frameIconName = appres.getResourceString( "installerFrame.icon", "appres/images/FreeInstaller-icon.gif" ); 83 84 Font entryFont = new Font( "DialogInput", Font.BOLD, 12 ); 88 Font labelFont = new Font( "Dialog", Font.BOLD, 12 ); 89 Font textFont = new Font( "Monospaced", Font.PLAIN, 12 ); 90 91 getContentPane().setLayout( new BorderLayout(9,9)); 92 93 Image img1 = appres.getImage( "images", frameIconName, null ); 94 setIconImage( img1 ); 95 96 JPanel panel = new JPanel(); 97 panel.setLayout( new BorderLayout( 3, 3 ) ); 98 99 textPane = new JTextPane(); 101 textPane.setFont(textFont); 102 textPane.setBackground(Color.black); 103 textPane.setEditable(false); 104 105 JScrollPane scrollTextPane = new JScrollPane(textPane) { 106 public Dimension getPreferredSize() { 107 Dimension size = getSize(); 108 if (size.width < 650) 109 size.width = 650; 110 if (size.height < 450) 111 size.height = 450; 112 return (size); 113 } 114 }; 115 116 panel.add( scrollTextPane, BorderLayout.CENTER ); 117 118 JPanel lowerBox = new JPanel(); 119 lowerBox.setLayout( new BorderLayout(1,1) ); 120 121 JPanel anyPanel = new JPanel(); 123 anyPanel.setLayout( new BorderLayout(1,1) ); 124 125 progressBarNode = new JProgressBar() { 126 public Dimension getPreferredSize() { 127 Dimension size = getSize(); 128 if (size.width < 100) 129 size.width = 100; 130 if (size.height != 24) 131 size.height = 24; 132 return (size); 133 } 134 }; 135 progressBarNode.setMinimum(0); 136 progressBarNode.setValue(100); 137 progressBarNode.setMinimum(100); 138 anyPanel.add( progressBarNode, BorderLayout.WEST ); 139 140 progressBarFile = new JProgressBar() { 141 public Dimension getPreferredSize() { 142 Dimension size = getSize(); 143 if (size.width < 100) 144 size.width = 100; 145 if (size.height != 24) 146 size.height = 24; 147 return (size); 148 } 149 }; 150 progressBarFile.setMinimum(0); 151 progressBarFile.setValue(100); 152 progressBarFile.setMinimum(100); 153 anyPanel.add( progressBarFile, BorderLayout.CENTER ); 154 155 lowerBox.add( anyPanel, BorderLayout.WEST ); 156 157 Border loweredBorder = new BevelBorder( BevelBorder.LOWERED ); 159 label = new JLabel( "-*- Status -*-" ); 160 label.setFont(labelFont); 161 label.setBorder(loweredBorder); 162 lowerBox.add( label, BorderLayout.CENTER ); 163 164 DigitalClock clock = new DigitalClock(); 166 clock.start(); 167 clock.setBorder(loweredBorder); 168 lowerBox.add( clock, BorderLayout.EAST ); 169 170 panel.add( lowerBox, BorderLayout.SOUTH ); 171 172 getContentPane().add( panel, BorderLayout.CENTER ); 173 174 setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); 175 176 printInfo( "**** OUTPUT FROM INSTALLATION PROCESS ****\n" ); 177 } 180 181 182 public void setStatusText( String newText ) 183 { 184 label.setText(newText); 185 } 186 187 188 public JProgressBar getProgressBarNode() 189 { 190 return (progressBarNode); 191 } 192 193 194 public JProgressBar getProgressBarFile() 195 { 196 return (progressBarFile); 197 } 198 199 203 public void setVisible( boolean visible ) 204 { 205 if (visible) { 206 Dimension size = getSize(); 207 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); 208 209 if (screen.width > 1100 ) { 210 size.width = screen.width*14/17; 212 size.height = screen.height*12/17; 213 } 214 int x = (screen.width-size.width)/2; 215 int y = (screen.height-size.height)/2; 216 setBounds(x, y, size.width, size.height); 217 } 218 219 super.setVisible(visible); 220 } 221 222 225 public void printInfo( String msg ) 226 { 227 SimpleAttributeSet attrs = new SimpleAttributeSet(); 228 StyleConstants.setForeground( attrs, Color.green ); 229 printMessage( msg, attrs ); 230 } 231 232 235 public void printWarning( String msg ) 236 { 237 SimpleAttributeSet attrs = new SimpleAttributeSet(); 238 StyleConstants.setForeground( attrs, Color.yellow ); 239 printMessage( "*WARNING* : "+ msg, attrs ); 240 } 241 242 245 public void printError( String msg ) 246 { 247 SimpleAttributeSet attrs = new SimpleAttributeSet(); 248 StyleConstants.setForeground( attrs, Color.magenta ); 249 StyleConstants.setBold( attrs, true ); 250 printMessage( "*ERROR* : "+msg, attrs ); 251 } 252 253 257 protected void printMessage( String msg, AttributeSet attrs ) 258 { 259 Document doc = textPane.getDocument(); 260 msg += "\n"; 262 try { 263 doc.insertString( doc.getLength(), msg, attrs ); 264 textPane.setCaretPosition( doc.getLength() ); 266 } 267 catch (BadLocationException ex) { 268 ex.printStackTrace(); 269 } 270 } 271 } 272 273 | Popular Tags |