1 package installer; 2 3 import javax.swing.*; 4 import java.awt.*; 5 import java.awt.event.*; 6 public class NavPanel extends JPanel implements ActionListener { 7 8 NavPanel(InstallWizard wizard, boolean bBack, boolean bNext, boolean bCancel, String prev, String next) { 9 setBackground(Color.white); 10 setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.LOWERED)); 11 this.wizard = wizard; 12 this.next = next; 13 this.prev = prev; 14 navBack = new javax.swing.JButton("<< Back"); 15 navNext = new javax.swing.JButton("Next >>"); 16 navCancel = new javax.swing.JButton("Cancel"); 17 setLayout(new GridBagLayout()); 18 19 gridBagConstraints1 = new java.awt.GridBagConstraints(); 20 gridBagConstraints1.insets = new java.awt.Insets(1, 1, 1, 1); 21 gridBagConstraints1.anchor = gridBagConstraints1.WEST; 22 23 gridBagConstraints2 = new java.awt.GridBagConstraints(); 24 gridBagConstraints2.gridx = 2; 25 gridBagConstraints2.gridy = 0; 26 27 gridBagConstraints3 = new java.awt.GridBagConstraints(); 28 gridBagConstraints3.gridx = 6; 29 gridBagConstraints3.gridy = 0; 30 31 navNext.setEnabled(bNext); 32 navBack.setEnabled(bBack); 33 navCancel.setEnabled(bCancel); 34 navNext.addActionListener(this); 35 navBack.addActionListener(this); 36 navCancel.addActionListener(this); 37 add(navBack, gridBagConstraints1); 38 add(navNext, gridBagConstraints2); 39 add(navCancel, gridBagConstraints3); 40 } 41 42 public void enableNext(boolean bEnable) { 43 navNext.setEnabled(bEnable); 44 } 45 46 public void enableBack(boolean bEnable) { 47 navBack.setEnabled(bEnable); 48 } 49 50 public void enableCancel(boolean bEnable) { 51 navCancel.setEnabled(bEnable); 52 } 53 54 public void enableIDE(boolean bEnable) { 55 ideDetected = bEnable; 56 } 57 58 public void actionPerformed(ActionEvent ev) { 59 if ((ev.getSource() == navNext) && (next.length() != 0)) { 60 wizard.show(next); 61 } 62 if ((ev.getSource() == navBack) && (prev.length() != 0)) { 63 wizard.show(prev); 64 } 65 if (ev.getSource() == navCancel) { 66 if( ideDetected ) { 67 wizard.show(InstallWizard.IDEWELCOME); 68 } 69 else { 70 wizard.exitForm(null); 71 } 72 enableIDE(false); 73 } 74 } 75 76 public void setNextListener(ActionListener listener) { 77 navNext.addActionListener(listener); 78 } 79 80 public void setBackListener(ActionListener listener) { 81 navBack.addActionListener(listener); 82 } 83 84 public void setCancelListener(ActionListener listener) { 85 navCancel.addActionListener(listener); 86 } 87 88 public void removeNextListener(ActionListener listener) 89 { 90 navNext.removeActionListener(listener); 91 } 92 93 public void removeBackListener(ActionListener listener) 94 { 95 navBack.removeActionListener(listener); 96 } 97 98 public void removeCancelListener(ActionListener listener) 99 { 100 navCancel.removeActionListener(listener); 101 } 102 103 public JButton navBack; 104 public JButton navNext; 105 public JButton navCancel; 106 private GridBagConstraints gridBagConstraints1; 107 private GridBagConstraints gridBagConstraints2; 108 private GridBagConstraints gridBagConstraints3; 109 private InstallWizard wizard; 110 private String next; 111 private String prev; 112 private boolean ideDetected = false; 113 } 114