1 2 24 package org.enhydra.tool.common.wizard; 25 26 import org.enhydra.tool.common.InnerPanel; 28 29 import java.awt.*; 31 import javax.swing.*; 32 import java.beans.Beans ; 33 public class TBWizardInnerPanel extends InnerPanel { 35 private final String FILE_WIZARD_JPG = 36 "org/enhydra/tool/common/media/lutris/otterwizard.jpg"; private BorderLayout layoutImage; 38 private boolean showImage = true; 39 private GridBagLayout layoutMain = null; 40 private JPanel panelImage; 41 private JLabel labelImage; 42 private TBWizardDeck deck = null; 43 44 public TBWizardInnerPanel() { 45 try { 46 jbInit(); 47 pmInit(); 48 } catch (Exception ex) { 49 ex.printStackTrace(); 50 } 51 } 52 53 public TBWizardDeck getDeck() { 54 return deck; 55 } 56 57 public void setDeck(TBWizardDeck d) { 58 Component[] comps = new Component[0]; 59 60 deck = d; 61 deck.setMinimumSize(new Dimension(100, 100)); 62 deck.setPreferredSize(new Dimension(100, 100)); 63 comps = getComponents(); 64 for (int i = 0; i < comps.length; i++) { 65 if (comps[i] instanceof TBWizardDeck) { 66 remove(comps[i]); 67 } 68 } 69 this.add(deck, 70 new GridBagConstraints(1, 0, 1, 1, 0.9, 0.9, 71 GridBagConstraints.CENTER, 72 GridBagConstraints.BOTH, 73 new Insets(2, 2, 2, 2), 0, 0)); 74 75 } 76 77 public void setLargeIcon(Icon icon) { 78 if (icon == null) { 79 panelImage.setVisible(false); 80 labelImage.setIcon(null); 81 } else { 82 panelImage.setVisible(true); 83 labelImage.setText(new String ()); 84 labelImage.setIcon(icon); 85 } 86 } 87 88 public Icon getLargeIcon() { 89 return labelImage.getIcon(); 90 } 91 92 public void save() { 94 } 96 97 98 protected Component[] getFirstFocusComponents() { 100 Component[] comps = new Component[0]; 101 TBWizardPage pageOne = null; 102 if (getDeck() == null) { 103 comps = super.getFirstFocusComponents(); 104 } else if (getDeck().getPages().length > 0) { 105 pageOne = getDeck().getPages()[0]; 106 comps = pageOne.getChildPanelComponents(); 107 } else { 108 comps = super.getFirstFocusComponents(); 109 } 110 return comps; 111 } 112 113 114 121 public void addWizardPage(TBWizardPage page) { 122 deck.addWizardPage(page); 123 } 124 125 private void jbInit() throws Exception { 126 layoutMain = 127 (GridBagLayout) Beans.instantiate(getClass().getClassLoader(), 128 GridBagLayout.class.getName()); 129 deck = (TBWizardDeck) Beans.instantiate(getClass().getClassLoader(), 130 TBWizardDeck.class.getName()); 131 panelImage = (JPanel) Beans.instantiate(getClass().getClassLoader(), 132 JPanel.class.getName()); 133 layoutImage = 134 (BorderLayout) Beans.instantiate(getClass().getClassLoader(), 135 BorderLayout.class.getName()); 136 labelImage = (JLabel) Beans.instantiate(getClass().getClassLoader(), 137 JLabel.class.getName()); 138 panelImage.setLayout(layoutImage); 139 panelImage.add(labelImage, BorderLayout.CENTER); 140 this.setLayout(layoutMain); 141 this.add(panelImage, 142 new GridBagConstraints(0, 0, 1, 1, 0.1, 0.1, 143 GridBagConstraints.CENTER, 144 GridBagConstraints.NONE, 145 new Insets(2, 2, 2, 2), 0, 0)); 146 this.add(deck, 147 new GridBagConstraints(1, 0, 1, 1, 0.9, 0.9, 148 GridBagConstraints.CENTER, 149 GridBagConstraints.BOTH, 150 new Insets(2, 2, 2, 2), 0, 0)); 151 152 } 153 154 private void pmInit() { 155 setDeck(deck); 156 ImageIcon image = null; 157 try { 158 image = new ImageIcon(this.getClass().getClassLoader().getResource(FILE_WIZARD_JPG)); 160 } catch (NullPointerException e) { 164 image = null; 165 } 166 setLargeIcon(image); 167 } 168 169 } 170 | Popular Tags |