KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > yagga > miniinstaller > gui > NavPanel


1 /*
2  * This file is part of MiniInstaller, a self installer builder for Java
3  * Copyright (C) 2002 Walter Gamba
4  * mailto:walter@yagga.net
5  * http://www.yagga.net/java/miniinstaller
6  *
7  * MiniInstaller is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * MiniInstaller is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  *
21  * As the time of writing, the GNU General Public Licene can be
22  * found at http://www.gnu.org/licenses/gpl.txt
23  *
24  */

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 JavaDoc ex) {
47       ex.printStackTrace();
48     }
49   }
50
51   void jbInit() throws Exception JavaDoc {
52     //btExit.setText("jButton1");
53
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.setText("jButton2");
59
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.setText("jButton3");
64
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 JavaDoc eBorder=new javax.swing.border.EtchedBorder JavaDoc();
70     spSep.setBorder(eBorder);
71
72         this.setLayout(gridBagLayout1);
73         this.setBackground(InstallFrame.BK_COL);
74     this.setMinimumSize(new Dimension(100, 36));
75         //this.setPreferredSize(new Dimension(200, 38));
76
//this.setMaximumSize(new Dimension(2000, 38));
77
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   /**
107   */

108   public void enableButtons(boolean exitEn, boolean bkEn, boolean fwdEn){
109     //Ut.infoln("BUTTONS: enable"+exitEn+" "+bkEn+" "+fwdEn);
110
btExit.setEnabled(exitEn);
111   // btBk.setEnabled(bkEn);//in the future.. for the moment...
112
btBk.setEnabled(bkEn);//in the future.. for the moment...
113

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 JavaDoc 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