1
16package org.tp23.antinstaller.renderer.swing;
17
18import java.awt.BorderLayout;
19import java.io.ByteArrayOutputStream;
20import java.io.InputStream;
21
22import javax.swing.ImageIcon;
23import javax.swing.JLabel;
24
25import org.tp23.antinstaller.ValidationException;
26import org.tp23.antinstaller.page.SplashPage;
27import org.tp23.antinstaller.runtime.ConfigurationException;
28
33public class SplashPageRenderer extends SwingPageRenderer{
34
35 private JLabel imagePanel = new JLabel();
36
37 public SplashPageRenderer() {
38 }
39 public boolean validateFields()throws ValidationException{
40 return true;
41 }
42
43 public void instanceInit() throws Exception {
44 String resource = ((SplashPage)page).getSplashResource();
45 ByteArrayOutputStream baos = new ByteArrayOutputStream();
46 InputStream in = this.getClass().getResourceAsStream(resource);
47 if(in == null) {
48 throw new ConfigurationException("Splash page resource is missing: " + resource);
49 }
50 byte[] buffer = new byte[2048];
51 int read = -1;
52 while ( (read = in.read(buffer)) != -1) {
53 baos.write(buffer, 0, read);
54 }
55 ImageIcon icon = new ImageIcon(baos.toByteArray());
56 imagePanel.setHorizontalAlignment(JLabel.CENTER);
57 imagePanel.setIcon(icon);
58 this.add(imagePanel, BorderLayout.CENTER);
59 }
60
61 public void updateInputFields(){
62 ;
63 }
64
65
66
67
70 public void updateDefaultValues() {
71 }
72}
73