KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.swing.JFileChooser JavaDoc;
28 import javax.swing.JRadioButton JavaDoc;
29 import javax.swing.event.ChangeEvent JavaDoc;
30 import javax.swing.event.ChangeListener JavaDoc;
31
32 import net.sf.launch4j.FileChooserFilter;
33 import net.sf.launch4j.binding.Bindings;
34 import net.sf.launch4j.config.Config;
35 import net.sf.launch4j.form.BasicForm;
36
37 /**
38  * @author Copyright (C) 2006 Grzegorz Kowal
39  */

40 public class BasicFormImpl extends BasicForm {
41
42     public BasicFormImpl(Bindings bindings, JFileChooser JavaDoc fc) {
43         bindings.add("outfile", _outfileField)
44                 .add("dontWrapJar", _dontWrapJarCheck)
45                 .add("jar", _jarField)
46                 .add("icon", _iconField)
47                 .add("cmdLine", _cmdLineField)
48                 .add("errTitle", _errorTitleField)
49                 .add("downloadUrl", _downloadUrlField, Config.DOWNLOAD_URL)
50                 .add("supportUrl", _supportUrlField)
51                 .add("chdir", _chdirField)
52                 .add("priorityIndex", new JRadioButton JavaDoc[] { _normalPriorityRadio,
53                                                             _idlePriorityRadio,
54                                                             _highPriorityRadio })
55                 .add("customProcName", _customProcNameCheck)
56                 .add("stayAlive", _stayAliveCheck);
57
58         _dontWrapJarCheck.addChangeListener(new DontWrapJarChangeListener());
59
60         _outfileButton.addActionListener(new BrowseActionListener(true, fc,
61                 new FileChooserFilter("Windows executables (.exe)", ".exe"),
62                 _outfileField));
63         _jarButton.addActionListener(new BrowseActionListener(false, fc,
64                 new FileChooserFilter("Jar files", ".jar"), _jarField));
65         _iconButton.addActionListener(new BrowseActionListener(false, fc,
66                 new FileChooserFilter("Icon files (.ico)", ".ico"), _iconField));
67     }
68
69     private class DontWrapJarChangeListener implements ChangeListener JavaDoc {
70
71         public void stateChanged(ChangeEvent JavaDoc e) {
72             boolean dontWrap = _dontWrapJarCheck.isSelected();
73             if (dontWrap) {
74                 _jarLabel.setIcon(loadImage("images/asterix-o.gif"));
75                 _jarLabel.setText(Messages.getString("jarPath"));
76                 _jarField.setToolTipText(Messages.getString("jarPathTip"));
77             } else {
78                 _jarLabel.setIcon(loadImage("images/asterix.gif"));
79                 _jarLabel.setText(Messages.getString("jar"));
80                 _jarField.setToolTipText(Messages.getString("jarTip"));
81             }
82             _jarButton.setEnabled(!dontWrap);
83         }
84     }
85 }
86
Popular Tags