1 package net.sf.launch4j.form; 2 3 import com.jgoodies.forms.layout.CellConstraints; 4 import com.jgoodies.forms.layout.FormLayout; 5 import java.awt.BorderLayout ; 6 import java.awt.Container ; 7 import java.awt.Dimension ; 8 import javax.swing.Box ; 9 import javax.swing.ImageIcon ; 10 import javax.swing.JButton ; 11 import javax.swing.JCheckBox ; 12 import javax.swing.JComboBox ; 13 import javax.swing.JLabel ; 14 import javax.swing.JPanel ; 15 import javax.swing.JScrollPane ; 16 import javax.swing.JTextArea ; 17 import javax.swing.JTextField ; 18 19 public abstract class JreForm extends JPanel 20 { 21 protected final JLabel _jrePathLabel = new JLabel (); 22 protected final JLabel _jreMinLabel = new JLabel (); 23 protected final JLabel _jreMaxLabel = new JLabel (); 24 protected final JLabel _jvmOptionsTextLabel = new JLabel (); 25 protected final JTextField _jrePathField = new JTextField (); 26 protected final JTextField _jreMinField = new JTextField (); 27 protected final JTextField _jreMaxField = new JTextField (); 28 protected final JTextArea _jvmOptionsTextArea = new JTextArea (); 29 protected final JLabel _initialHeapSizeLabel = new JLabel (); 30 protected final JLabel _maxHeapSizeLabel = new JLabel (); 31 protected final JTextField _initialHeapSizeField = new JTextField (); 32 protected final JTextField _maxHeapSizeField = new JTextField (); 33 protected final JCheckBox _dontUsePrivateJresCheck = new JCheckBox (); 34 protected final JComboBox _varCombo = new JComboBox (); 35 protected final JButton _propertyButton = new JButton (); 36 protected final JButton _optionButton = new JButton (); 37 protected final JButton _envPropertyButton = new JButton (); 38 protected final JButton _envOptionButton = new JButton (); 39 protected final JTextField _envVarField = new JTextField (); 40 41 44 public JreForm() 45 { 46 initializePanel(); 47 } 48 49 55 void addFillComponents( Container panel, int[] cols, int[] rows ) 56 { 57 Dimension filler = new Dimension (10,10); 58 59 boolean filled_cell_11 = false; 60 CellConstraints cc = new CellConstraints(); 61 if ( cols.length > 0 && rows.length > 0 ) 62 { 63 if ( cols[0] == 1 && rows[0] == 1 ) 64 { 65 66 panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); 67 filled_cell_11 = true; 68 } 69 } 70 71 for( int index = 0; index < cols.length; index++ ) 72 { 73 if ( cols[index] == 1 && filled_cell_11 ) 74 { 75 continue; 76 } 77 panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); 78 } 79 80 for( int index = 0; index < rows.length; index++ ) 81 { 82 if ( rows[index] == 1 && filled_cell_11 ) 83 { 84 continue; 85 } 86 panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); 87 } 88 89 } 90 91 97 public ImageIcon loadImage( String imageName ) 98 { 99 try 100 { 101 ClassLoader classloader = getClass().getClassLoader(); 102 java.net.URL url = classloader.getResource( imageName ); 103 if ( url != null ) 104 { 105 ImageIcon icon = new ImageIcon ( url ); 106 return icon; 107 } 108 } 109 catch( Exception e ) 110 { 111 e.printStackTrace(); 112 } 113 throw new IllegalArgumentException ( "Unable to load image: " + imageName ); 114 } 115 116 public JPanel createPanel() 117 { 118 JPanel jpanel1 = new JPanel (); 119 FormLayout formlayout1 = new FormLayout("FILL:7DLU:NONE,RIGHT:MAX(65DLU;DEFAULT):NONE,FILL:3DLU:NONE,FILL:60DLU:NONE,FILL:3DLU:NONE,FILL:DEFAULT:NONE,FILL:7DLU:NONE,FILL:DEFAULT:GROW(1.0),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,FILL:50DLU:GROW(1.0),CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:9DLU:NONE"); 120 CellConstraints cc = new CellConstraints(); 121 jpanel1.setLayout(formlayout1); 122 123 _jrePathLabel.setIcon(loadImage("images/asterix-o.gif")); 124 _jrePathLabel.setName("jrePathLabel"); 125 _jrePathLabel.setText(Messages.getString("jrePath")); 126 jpanel1.add(_jrePathLabel,cc.xy(2,2)); 127 128 _jreMinLabel.setIcon(loadImage("images/asterix-o.gif")); 129 _jreMinLabel.setName("jreMinLabel"); 130 _jreMinLabel.setText(Messages.getString("jreMin")); 131 jpanel1.add(_jreMinLabel,cc.xy(2,4)); 132 133 _jreMaxLabel.setName("jreMaxLabel"); 134 _jreMaxLabel.setText(Messages.getString("jreMax")); 135 jpanel1.add(_jreMaxLabel,cc.xy(2,6)); 136 137 _jvmOptionsTextLabel.setName("jvmOptionsTextLabel"); 138 _jvmOptionsTextLabel.setText(Messages.getString("jvmOptions")); 139 jpanel1.add(_jvmOptionsTextLabel,new CellConstraints(2,12,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); 140 141 _jrePathField.setName("jrePathField"); 142 _jrePathField.setToolTipText(Messages.getString("jrePathTip")); 143 jpanel1.add(_jrePathField,cc.xywh(4,2,5,1)); 144 145 _jreMinField.setName("jreMinField"); 146 jpanel1.add(_jreMinField,cc.xy(4,4)); 147 148 _jreMaxField.setName("jreMaxField"); 149 jpanel1.add(_jreMaxField,cc.xy(4,6)); 150 151 _jvmOptionsTextArea.setName("jvmOptionsTextArea"); 152 _jvmOptionsTextArea.setToolTipText(Messages.getString("jvmOptionsTip")); 153 JScrollPane jscrollpane1 = new JScrollPane (); 154 jscrollpane1.setViewportView(_jvmOptionsTextArea); 155 jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 156 jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 157 jpanel1.add(jscrollpane1,cc.xywh(4,12,5,1)); 158 159 _initialHeapSizeLabel.setName("initialHeapSizeLabel"); 160 _initialHeapSizeLabel.setText(Messages.getString("initialHeapSize")); 161 jpanel1.add(_initialHeapSizeLabel,cc.xy(2,8)); 162 163 _maxHeapSizeLabel.setName("maxHeapSizeLabel"); 164 _maxHeapSizeLabel.setText(Messages.getString("maxHeapSize")); 165 jpanel1.add(_maxHeapSizeLabel,cc.xy(2,10)); 166 167 JLabel jlabel1 = new JLabel (); 168 jlabel1.setText("MB"); 169 jpanel1.add(jlabel1,cc.xy(6,8)); 170 171 JLabel jlabel2 = new JLabel (); 172 jlabel2.setText("MB"); 173 jpanel1.add(jlabel2,cc.xy(6,10)); 174 175 _initialHeapSizeField.setName("initialHeapSizeField"); 176 jpanel1.add(_initialHeapSizeField,cc.xy(4,8)); 177 178 _maxHeapSizeField.setName("maxHeapSizeField"); 179 jpanel1.add(_maxHeapSizeField,cc.xy(4,10)); 180 181 _dontUsePrivateJresCheck.setActionCommand("Include private JREs in search"); 182 _dontUsePrivateJresCheck.setName("dontUsePrivateJresCheck"); 183 _dontUsePrivateJresCheck.setText(Messages.getString("dontUsePrivateJres")); 184 jpanel1.add(_dontUsePrivateJresCheck,cc.xy(8,4)); 185 186 jpanel1.add(createPanel1(),cc.xywh(2,14,7,1)); 187 addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }); 188 return jpanel1; 189 } 190 191 public JPanel createPanel1() 192 { 193 JPanel jpanel1 = new JPanel (); 194 FormLayout formlayout1 = new FormLayout("RIGHT:MAX(65DLU;DEFAULT):NONE,FILL:3DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:3DLU:NONE,FILL:DEFAULT:NONE,FILL:3DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE"); 195 CellConstraints cc = new CellConstraints(); 196 jpanel1.setLayout(formlayout1); 197 198 _varCombo.setName("varCombo"); 199 jpanel1.add(_varCombo,cc.xy(3,1)); 200 201 _propertyButton.setActionCommand("Add"); 202 _propertyButton.setIcon(loadImage("images/edit_add16.png")); 203 _propertyButton.setName("propertyButton"); 204 _propertyButton.setText(Messages.getString("property")); 205 _propertyButton.setToolTipText(Messages.getString("propertyTip")); 206 jpanel1.add(_propertyButton,cc.xy(5,1)); 207 208 _optionButton.setActionCommand("Add"); 209 _optionButton.setIcon(loadImage("images/edit_add16.png")); 210 _optionButton.setName("optionButton"); 211 _optionButton.setText(Messages.getString("option")); 212 _optionButton.setToolTipText(Messages.getString("optionTip")); 213 jpanel1.add(_optionButton,cc.xy(7,1)); 214 215 _envPropertyButton.setActionCommand("Add"); 216 _envPropertyButton.setIcon(loadImage("images/edit_add16.png")); 217 _envPropertyButton.setName("envPropertyButton"); 218 _envPropertyButton.setText(Messages.getString("property")); 219 _envPropertyButton.setToolTipText(Messages.getString("propertyTip")); 220 jpanel1.add(_envPropertyButton,cc.xy(5,3)); 221 222 JLabel jlabel1 = new JLabel (); 223 jlabel1.setText(Messages.getString("varsAndRegistry")); 224 jpanel1.add(jlabel1,cc.xy(1,1)); 225 226 JLabel jlabel2 = new JLabel (); 227 jlabel2.setIcon(loadImage("images/asterix.gif")); 228 jlabel2.setText(Messages.getString("envVar")); 229 jpanel1.add(jlabel2,cc.xy(1,3)); 230 231 _envOptionButton.setActionCommand("Add"); 232 _envOptionButton.setIcon(loadImage("images/edit_add16.png")); 233 _envOptionButton.setName("envOptionButton"); 234 _envOptionButton.setText(Messages.getString("option")); 235 _envOptionButton.setToolTipText(Messages.getString("optionTip")); 236 jpanel1.add(_envOptionButton,cc.xy(7,3)); 237 238 _envVarField.setName("envVarField"); 239 jpanel1.add(_envVarField,cc.xy(3,3)); 240 241 addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[]{ 2 }); 242 return jpanel1; 243 } 244 245 248 protected void initializePanel() 249 { 250 setLayout(new BorderLayout ()); 251 add(createPanel(), BorderLayout.CENTER); 252 } 253 254 255 } 256 | Popular Tags |