KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > launch4j > formimpl > HeaderFormImpl


1 /*
2     Launch4j (http://launch4j.sourceforge.net/)
3     Cross-platform Java application wrapper for creating Windows native executables.
4
5     Copyright (C) 2004, 2006 Grzegorz Kowal
6
7     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11
12     This program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */

21
22 /*
23  * Created on May 1, 2006
24  */

25 package net.sf.launch4j.formimpl;
26
27 import java.awt.event.ActionEvent JavaDoc;
28 import java.awt.event.ActionListener JavaDoc;
29
30 import javax.swing.JRadioButton JavaDoc;
31 import javax.swing.event.ChangeEvent JavaDoc;
32 import javax.swing.event.ChangeListener JavaDoc;
33
34 import net.sf.launch4j.binding.Binding;
35 import net.sf.launch4j.binding.Bindings;
36 import net.sf.launch4j.config.Config;
37 import net.sf.launch4j.config.ConfigPersister;
38 import net.sf.launch4j.form.HeaderForm;
39
40 /**
41  * @author Copyright (C) 2006 Grzegorz Kowal
42  */

43 public class HeaderFormImpl extends HeaderForm {
44     private final Bindings _bindings;
45
46     public HeaderFormImpl(Bindings bindings) {
47         _bindings = bindings;
48         _bindings.add("headerTypeIndex", new JRadioButton JavaDoc[] { _guiHeaderRadio,
49                                                         _consoleHeaderRadio })
50                 .add("headerObjects", "customHeaderObjects", _headerObjectsCheck,
51                                                             _headerObjectsTextArea)
52                 .add("libs", "customLibs", _libsCheck, _libsTextArea);
53
54         _guiHeaderRadio.addChangeListener(new HeaderTypeChangeListener());
55         _headerObjectsCheck.addActionListener(new HeaderObjectsActionListener());
56         _libsCheck.addActionListener(new LibsActionListener());
57     }
58
59     private class HeaderTypeChangeListener implements ChangeListener JavaDoc {
60         public void stateChanged(ChangeEvent JavaDoc e) {
61             Config c = ConfigPersister.getInstance().getConfig();
62             c.setHeaderType(_guiHeaderRadio.isSelected() ? Config.GUI_HEADER
63                                                         : Config.CONSOLE_HEADER);
64             if (!_headerObjectsCheck.isSelected()) {
65                 Binding b = _bindings.getBinding("headerObjects");
66                 b.put(c);
67             }
68         }
69     }
70
71     private class HeaderObjectsActionListener implements ActionListener JavaDoc {
72         public void actionPerformed(ActionEvent JavaDoc e) {
73             if (!_headerObjectsCheck.isSelected()) {
74                 ConfigPersister.getInstance().getConfig().setHeaderObjects(null);
75                 Binding b = _bindings.getBinding("headerObjects");
76                 b.put(ConfigPersister.getInstance().getConfig());
77             }
78         }
79     }
80
81     private class LibsActionListener implements ActionListener JavaDoc {
82         public void actionPerformed(ActionEvent JavaDoc e) {
83             if (!_libsCheck.isSelected()) {
84                 ConfigPersister.getInstance().getConfig().setLibs(null);
85                 Binding b = _bindings.getBinding("libs");
86                 b.put(ConfigPersister.getInstance().getConfig());
87             }
88         }
89     }
90 }
91
Popular Tags