1 package net.sf.launch4j.form; 2 3 import com.jeta.forms.components.separator.TitledSeparator; 4 import com.jgoodies.forms.layout.CellConstraints; 5 import com.jgoodies.forms.layout.FormLayout; 6 import java.awt.BorderLayout ; 7 import java.awt.Container ; 8 import java.awt.Dimension ; 9 import javax.swing.Box ; 10 import javax.swing.ButtonGroup ; 11 import javax.swing.ImageIcon ; 12 import javax.swing.JButton ; 13 import javax.swing.JCheckBox ; 14 import javax.swing.JLabel ; 15 import javax.swing.JPanel ; 16 import javax.swing.JRadioButton ; 17 import javax.swing.JTextField ; 18 19 public abstract class BasicForm extends JPanel 20 { 21 protected final JButton _outfileButton = new JButton (); 22 protected final JLabel _outfileLabel = new JLabel (); 23 protected final JLabel _iconLabel = new JLabel (); 24 protected final JLabel _jarLabel = new JLabel (); 25 protected final JButton _jarButton = new JButton (); 26 protected final JButton _iconButton = new JButton (); 27 protected final JLabel _cmdLineLabel = new JLabel (); 28 protected final JLabel _optionsLabel = new JLabel (); 29 protected final JLabel _chdirLabel = new JLabel (); 30 protected final JLabel _processPriorityLabel = new JLabel (); 31 protected final JRadioButton _normalPriorityRadio = new JRadioButton (); 32 protected final ButtonGroup _buttongroup1 = new ButtonGroup (); 33 protected final JRadioButton _idlePriorityRadio = new JRadioButton (); 34 protected final JRadioButton _highPriorityRadio = new JRadioButton (); 35 protected final JCheckBox _customProcNameCheck = new JCheckBox (); 36 protected final JCheckBox _stayAliveCheck = new JCheckBox (); 37 protected final JTextField _cmdLineField = new JTextField (); 38 protected final JTextField _chdirField = new JTextField (); 39 protected final JTextField _iconField = new JTextField (); 40 protected final JCheckBox _dontWrapJarCheck = new JCheckBox (); 41 protected final JTextField _jarField = new JTextField (); 42 protected final JTextField _outfileField = new JTextField (); 43 protected final JLabel _errorTitleLabel = new JLabel (); 44 protected final JTextField _errorTitleField = new JTextField (); 45 protected final JLabel _downloadUrlLabel = new JLabel (); 46 protected final JTextField _downloadUrlField = new JTextField (); 47 protected final JLabel _supportUrlLabel = new JLabel (); 48 protected final JTextField _supportUrlField = new JTextField (); 49 50 53 public BasicForm() 54 { 55 initializePanel(); 56 } 57 58 64 void addFillComponents( Container panel, int[] cols, int[] rows ) 65 { 66 Dimension filler = new Dimension (10,10); 67 68 boolean filled_cell_11 = false; 69 CellConstraints cc = new CellConstraints(); 70 if ( cols.length > 0 && rows.length > 0 ) 71 { 72 if ( cols[0] == 1 && rows[0] == 1 ) 73 { 74 75 panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); 76 filled_cell_11 = true; 77 } 78 } 79 80 for( int index = 0; index < cols.length; index++ ) 81 { 82 if ( cols[index] == 1 && filled_cell_11 ) 83 { 84 continue; 85 } 86 panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); 87 } 88 89 for( int index = 0; index < rows.length; index++ ) 90 { 91 if ( rows[index] == 1 && filled_cell_11 ) 92 { 93 continue; 94 } 95 panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); 96 } 97 98 } 99 100 106 public ImageIcon loadImage( String imageName ) 107 { 108 try 109 { 110 ClassLoader classloader = getClass().getClassLoader(); 111 java.net.URL url = classloader.getResource( imageName ); 112 if ( url != null ) 113 { 114 ImageIcon icon = new ImageIcon ( url ); 115 return icon; 116 } 117 } 118 catch( Exception e ) 119 { 120 e.printStackTrace(); 121 } 122 throw new IllegalArgumentException ( "Unable to load image: " + imageName ); 123 } 124 125 public JPanel createPanel() 126 { 127 JPanel jpanel1 = new JPanel (); 128 FormLayout formlayout1 = new FormLayout("FILL:7DLU:NONE,RIGHT:MAX(65DLU;DEFAULT):NONE,FILL:3DLU:NONE,FILL:DEFAULT:NONE,FILL:7DLU:NONE,FILL:DEFAULT:NONE,FILL:7DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:3DLU:NONE,FILL:26PX:NONE,FILL:7DLU:NONE","CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:9DLU:NONE"); 129 CellConstraints cc = new CellConstraints(); 130 jpanel1.setLayout(formlayout1); 131 132 _outfileButton.setIcon(loadImage("images/open16.png")); 133 _outfileButton.setName("outfileButton"); 134 jpanel1.add(_outfileButton,cc.xy(12,2)); 135 136 _outfileLabel.setIcon(loadImage("images/asterix.gif")); 137 _outfileLabel.setName("outfileLabel"); 138 _outfileLabel.setText(Messages.getString("outfile")); 139 jpanel1.add(_outfileLabel,cc.xy(2,2)); 140 141 _iconLabel.setName("iconLabel"); 142 _iconLabel.setText(Messages.getString("icon")); 143 jpanel1.add(_iconLabel,cc.xy(2,8)); 144 145 _jarLabel.setIcon(loadImage("images/asterix.gif")); 146 _jarLabel.setName("jarLabel"); 147 _jarLabel.setText(Messages.getString("jar")); 148 jpanel1.add(_jarLabel,cc.xy(2,4)); 149 150 _jarButton.setIcon(loadImage("images/open16.png")); 151 _jarButton.setName("jarButton"); 152 jpanel1.add(_jarButton,cc.xy(12,4)); 153 154 _iconButton.setIcon(loadImage("images/open16.png")); 155 _iconButton.setName("iconButton"); 156 jpanel1.add(_iconButton,cc.xy(12,8)); 157 158 _cmdLineLabel.setName("cmdLineLabel"); 159 _cmdLineLabel.setText(Messages.getString("cmdLine")); 160 _cmdLineLabel.setToolTipText(""); 161 jpanel1.add(_cmdLineLabel,cc.xy(2,12)); 162 163 _optionsLabel.setName("optionsLabel"); 164 _optionsLabel.setText(Messages.getString("options")); 165 jpanel1.add(_optionsLabel,cc.xy(2,16)); 166 167 _chdirLabel.setName("chdirLabel"); 168 _chdirLabel.setText(Messages.getString("chdir")); 169 jpanel1.add(_chdirLabel,cc.xy(2,10)); 170 171 _processPriorityLabel.setName("processPriorityLabel"); 172 _processPriorityLabel.setText(Messages.getString("priority")); 173 jpanel1.add(_processPriorityLabel,cc.xy(2,14)); 174 175 _normalPriorityRadio.setActionCommand(Messages.getString("normalPriority")); 176 _normalPriorityRadio.setName("normalPriorityRadio"); 177 _normalPriorityRadio.setText(Messages.getString("normalPriority")); 178 _buttongroup1.add(_normalPriorityRadio); 179 jpanel1.add(_normalPriorityRadio,cc.xy(4,14)); 180 181 _idlePriorityRadio.setActionCommand(Messages.getString("idlePriority")); 182 _idlePriorityRadio.setName("idlePriorityRadio"); 183 _idlePriorityRadio.setText(Messages.getString("idlePriority")); 184 _buttongroup1.add(_idlePriorityRadio); 185 jpanel1.add(_idlePriorityRadio,cc.xy(6,14)); 186 187 _highPriorityRadio.setActionCommand(Messages.getString("highPriority")); 188 _highPriorityRadio.setName("highPriorityRadio"); 189 _highPriorityRadio.setText(Messages.getString("highPriority")); 190 _buttongroup1.add(_highPriorityRadio); 191 jpanel1.add(_highPriorityRadio,cc.xy(8,14)); 192 193 _customProcNameCheck.setActionCommand("Custom process name"); 194 _customProcNameCheck.setName("customProcNameCheck"); 195 _customProcNameCheck.setText(Messages.getString("customProcName")); 196 jpanel1.add(_customProcNameCheck,cc.xywh(4,16,7,1)); 197 198 _stayAliveCheck.setActionCommand("Stay alive after launching a GUI application"); 199 _stayAliveCheck.setName("stayAliveCheck"); 200 _stayAliveCheck.setText(Messages.getString("stayAlive")); 201 jpanel1.add(_stayAliveCheck,cc.xywh(4,18,7,1)); 202 203 _cmdLineField.setName("cmdLineField"); 204 _cmdLineField.setToolTipText(Messages.getString("cmdLineTip")); 205 jpanel1.add(_cmdLineField,cc.xywh(4,12,7,1)); 206 207 _chdirField.setName("chdirField"); 208 _chdirField.setToolTipText(Messages.getString("chdirTip")); 209 jpanel1.add(_chdirField,cc.xywh(4,10,7,1)); 210 211 _iconField.setName("iconField"); 212 _iconField.setToolTipText(Messages.getString("iconTip")); 213 jpanel1.add(_iconField,cc.xywh(4,8,7,1)); 214 215 _dontWrapJarCheck.setActionCommand("Don't wrap the jar, launch it only"); 216 _dontWrapJarCheck.setName("dontWrapJarCheck"); 217 _dontWrapJarCheck.setText(Messages.getString("dontWrapJar")); 218 jpanel1.add(_dontWrapJarCheck,cc.xywh(4,6,7,1)); 219 220 _jarField.setName("jarField"); 221 _jarField.setToolTipText(Messages.getString("jarTip")); 222 jpanel1.add(_jarField,cc.xywh(4,4,7,1)); 223 224 _outfileField.setName("outfileField"); 225 _outfileField.setToolTipText(Messages.getString("outfileTip")); 226 jpanel1.add(_outfileField,cc.xywh(4,2,7,1)); 227 228 TitledSeparator titledseparator1 = new TitledSeparator(); 229 titledseparator1.setText(Messages.getString("downloadAndSupport")); 230 jpanel1.add(titledseparator1,cc.xywh(2,20,11,1)); 231 232 _errorTitleLabel.setName("errorTitleLabel"); 233 _errorTitleLabel.setText(Messages.getString("errorTitle")); 234 jpanel1.add(_errorTitleLabel,cc.xy(2,22)); 235 236 _errorTitleField.setName("errorTitleField"); 237 _errorTitleField.setToolTipText(Messages.getString("errorTitleTip")); 238 jpanel1.add(_errorTitleField,cc.xywh(4,22,7,1)); 239 240 _downloadUrlLabel.setIcon(loadImage("images/asterix.gif")); 241 _downloadUrlLabel.setName("downloadUrlLabel"); 242 _downloadUrlLabel.setText(Messages.getString("downloadUrl")); 243 jpanel1.add(_downloadUrlLabel,cc.xy(2,24)); 244 245 _downloadUrlField.setName("downloadUrlField"); 246 jpanel1.add(_downloadUrlField,cc.xywh(4,24,7,1)); 247 248 _supportUrlLabel.setName("supportUrlLabel"); 249 _supportUrlLabel.setText(Messages.getString("supportUrl")); 250 jpanel1.add(_supportUrlLabel,cc.xy(2,26)); 251 252 _supportUrlField.setName("supportUrlField"); 253 jpanel1.add(_supportUrlField,cc.xywh(4,26,7,1)); 254 255 addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27 }); 256 return jpanel1; 257 } 258 259 262 protected void initializePanel() 263 { 264 setLayout(new BorderLayout ()); 265 add(createPanel(), BorderLayout.CENTER); 266 } 267 268 269 } 270 | Popular Tags |