1 25 26 package net.yagga.miniinstaller.gui; 27 28 import java.awt.*; 29 import javax.swing.*; 30 import java.awt.event.*; 31 import net.yagga.util.Ut; 32 33 public class NavPanel extends JPanel implements ActionListener{ 34 JButton btExit = new JButton(); 35 JButton btBk = new JButton(); 36 JButton btFwd = new JButton(); 37 JSeparator spSep = new JSeparator(SwingConstants.HORIZONTAL); 38 GridBagLayout gridBagLayout1 = new GridBagLayout(); 39 40 InstallFrame frame; 41 public NavPanel(InstallFrame i) { 42 frame=i; 43 try { 44 jbInit(); 45 } 46 catch (Exception ex) { 47 ex.printStackTrace(); 48 } 49 } 50 51 void jbInit() throws Exception { 52 component1 = Box.createHorizontalStrut(8); 54 btExit.setMaximumSize(new Dimension(95, 27)); 55 btExit.setMinimumSize(new Dimension(95, 27)); 56 btExit.setPreferredSize(new Dimension(95, 27)); 57 btExit.setText("Exit"); 58 btBk.setMaximumSize(new Dimension(95, 27)); 60 btBk.setMinimumSize(new Dimension(95, 27)); 61 btBk.setPreferredSize(new Dimension(95, 27)); 62 btBk.setText("<< Back"); 63 btFwd.setMaximumSize(new Dimension(95, 27)); 65 btFwd.setMinimumSize(new Dimension(95, 27)); 66 btFwd.setPreferredSize(new Dimension(95, 27)); 67 btFwd.setText("Fwd >>"); 68 spSep.setMinimumSize(new Dimension(10, 1)); 69 javax.swing.border.EtchedBorder eBorder=new javax.swing.border.EtchedBorder (); 70 spSep.setBorder(eBorder); 71 72 this.setLayout(gridBagLayout1); 73 this.setBackground(InstallFrame.BK_COL); 74 this.setMinimumSize(new Dimension(100, 36)); 75 this.setOpaque(true); 78 79 this.add(btExit, new GridBagConstraints(0, 1, 1, 2, 1.0, 0.0 80 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 10, 5, 0), 0, 0)); 81 this.add(btBk, new GridBagConstraints(2, 1, 1, 2, 1.0, 0.0 82 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 3, 5), 0, 0)); 83 this.add(btFwd, new GridBagConstraints(3, 1, 1, 2, 1.0, 0.0 84 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 3, 5), 0, 0)); 85 this.add(spSep, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0 86 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(3, 10, 0, 10), 383, 1)); 87 this.add(component1, new GridBagConstraints(1, 2, 1, 1, 2.0, 0.0 88 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 50, 0, 0), 0, 0)); 89 btExit.setOpaque(false); 90 btBk.setOpaque(false); 91 btFwd.setOpaque(false); 92 spSep.setOpaque(false); 93 btFwd.setForeground(InstallFrame.BTN_COL); 94 btBk.setForeground(InstallFrame.BTN_COL); 95 btExit.setForeground(InstallFrame.BTN_COL); 96 component1.setBackground(InstallFrame.BK_COL); 97 98 btExit.addActionListener(this); 99 btBk.addActionListener(this); 100 btFwd.addActionListener(this); 101 102 this.setPreferredSize(new Dimension(100,(int)getPreferredSize().getHeight())); 103 104 } 105 106 108 public void enableButtons(boolean exitEn, boolean bkEn, boolean fwdEn){ 109 btExit.setEnabled(exitEn); 111 btBk.setEnabled(bkEn); 114 btFwd.setEnabled(fwdEn); 115 } 116 boolean _final=false; 117 Component component1; 118 public void makeFinalPage(){ 119 enableButtons(false,true,true); 120 btFwd.setText("Done!"); 121 _final=true; 122 } 123 public void revertFinalPage(){ 124 enableButtons(true,true,true); 125 btFwd.setText("Fwd >>"); 126 _final=false; 127 } 128 public void refresh(){ 129 130 try { 131 jbInit(); 132 } 133 catch (Exception ex) { 134 ex.printStackTrace(); 135 } 136 } 137 138 public void actionPerformed(ActionEvent e){ 139 if(e.getSource()==btExit) 140 frame.exit(); 141 else if(e.getSource()==btBk) 142 frame.bk(); 143 else if(e.getSource()==btFwd){ 144 if(!_final) 145 frame.fwd(); 146 else 147 frame.exit(); 148 } 149 } 150 } 151 152 | Popular Tags |