1 25 26 package net.yagga.miniinstaller.gui; 27 28 import net.yagga.util.*; 29 import net.yagga.miniinstaller.Step; 30 import java.awt.*; 31 import javax.swing.*; 32 import java.net.*; 33 import java.io.*; 34 35 44 public class StepPanel extends JPanel implements InstallPanel{ 45 46 private Step steps[]; 47 JLabel ico1 = new JLabel(); 49 JLabel step1 = new JLabel(); 50 Icon icoOff=ResourceMgr.retrieveImageIcon("img/triOff.gif"); 52 Icon icoOn=ResourceMgr.retrieveImageIcon("img/triOn.gif"); 53 54 JLabel lbSteps[]; 55 JLabel lbIcos[]; 56 Font normal=null; 57 Font bold=null; 58 59 public StepPanel(Step steps[]) { 60 this.steps=steps; 61 try { 62 jbInit(); 63 } 64 catch (Exception ex) { 65 ex.printStackTrace(); 66 } 67 } 68 private ImageIcon loadImage(String image) { 69 ImageIcon img = new ImageIcon(StepPanel.class.getResource(image)); 70 return img; 71 } 72 73 74 void jbInit() throws Exception { 75 normal=GuiProperties.stepFont; 76 bold=GuiProperties.selectedStepFont; 77 78 JPanel rows=new JPanel(); 79 BoxLayout boxLayout=new BoxLayout(rows,BoxLayout.Y_AXIS); 80 rows.setLayout(boxLayout); 81 rows.setOpaque(false); 82 lbSteps=new JLabel[steps.length]; 83 lbIcos=new JLabel[steps.length]; 84 85 this.setBackground(InstallFrame.BK_COL); 86 for(int i=0;i<steps.length;i++){ 87 JPanel jp=new JPanel(); 88 jp.setLayout(new BoxLayout(jp,SwingConstants.HORIZONTAL)); 90 jp.setAlignmentX(Component.LEFT_ALIGNMENT); 91 lbSteps[i]=new JLabel(); 92 lbSteps[i].setOpaque(false); 93 lbSteps[i].setText(steps[i].name); 94 lbSteps[i].setFont(normal); 95 lbSteps[i].setForeground(InstallFrame.STEP_COL); 96 lbIcos[i]=new JLabel(); 97 lbIcos[i].setOpaque(false); 98 lbIcos[i].setIcon(icoOff); 99 jp.add(lbIcos[i],BorderLayout.WEST); 100 jp.add(lbSteps[i],BorderLayout.CENTER); 101 jp.setOpaque(false); 102 jp.doLayout(); 103 rows.add(jp); 104 } 105 rows.add(Box.createVerticalGlue()); 106 this.setLayout(new BorderLayout()); 108 this.add(rows,BorderLayout.CENTER); 109 JPanel p=new JPanel(); 110 p.setOpaque(false); 111 p.setLayout(new BoxLayout(p,BoxLayout.X_AXIS)); 112 p.add(Box.createHorizontalStrut(5)); 113 javax.swing.border.EtchedBorder eBorder=new javax.swing.border.EtchedBorder (); 114 JSeparator spSep=new JSeparator(SwingConstants.VERTICAL); 115 spSep.setBorder(eBorder); 116 p.add(spSep); 117 p.add(Box.createHorizontalStrut(5)); 118 this.add(p,BorderLayout.EAST); 119 rows.doLayout(); 120 this.doLayout(); 122 Dimension d=this.getPreferredSize(); 123 d.width+=10; 125 this.setPreferredSize(d); 126 this.setOpaque(true); 127 } 128 129 private int curStep=-1; 130 private int precStep=-1; 131 132 public void refresh(){ 133 try { 134 jbInit(); 135 } 136 catch (Exception ex) { 137 ex.printStackTrace(); 138 } 139 } 140 141 public void resetStep(){ 142 curStep=-1; 143 precStep=-1; 144 } 146 public void incStep(){ 147 curStep++; 148 setStep(curStep); 149 } 150 public void decStep(){ 151 curStep--; 152 setStep(curStep); 153 } 154 public void goStep(int to){ 155 for(int i=0;i<steps.length;i++) 156 if(steps[i].index==to) 157 curStep=i; 158 setStep(curStep); 159 } 160 private void setStep(int i){ 161 if(i<0 || i>=steps.length) 163 return; 164 if(precStep!=-1){ 165 lbIcos[precStep].setIcon(icoOff); 166 lbSteps[precStep].setFont(normal); 167 } 168 lbIcos[i].setIcon(icoOn); 170 lbSteps[i].setFont(bold); 171 172 precStep=i; 173 } 174 public void setDims(Dimension d){ 175 double w=getPreferredSize().getWidth(); 176 this.setPreferredSize(new Dimension((int)w,(int)d.getHeight())); 177 this.invalidate(); 178 } 179 180 } 181 182 183 184 | Popular Tags |