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.JLabel ; 11 import javax.swing.JPanel ; 12 import javax.swing.JScrollPane ; 13 import javax.swing.JTextArea ; 14 15 public abstract class EnvironmentVarsForm extends JPanel 16 { 17 protected final JTextArea _envVarsTextArea = new JTextArea (); 18 protected final JLabel _envVarsLabel = new JLabel (); 19 20 23 public EnvironmentVarsForm() 24 { 25 initializePanel(); 26 } 27 28 34 void addFillComponents( Container panel, int[] cols, int[] rows ) 35 { 36 Dimension filler = new Dimension (10,10); 37 38 boolean filled_cell_11 = false; 39 CellConstraints cc = new CellConstraints(); 40 if ( cols.length > 0 && rows.length > 0 ) 41 { 42 if ( cols[0] == 1 && rows[0] == 1 ) 43 { 44 45 panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); 46 filled_cell_11 = true; 47 } 48 } 49 50 for( int index = 0; index < cols.length; index++ ) 51 { 52 if ( cols[index] == 1 && filled_cell_11 ) 53 { 54 continue; 55 } 56 panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); 57 } 58 59 for( int index = 0; index < rows.length; index++ ) 60 { 61 if ( rows[index] == 1 && filled_cell_11 ) 62 { 63 continue; 64 } 65 panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); 66 } 67 68 } 69 70 76 public ImageIcon loadImage( String imageName ) 77 { 78 try 79 { 80 ClassLoader classloader = getClass().getClassLoader(); 81 java.net.URL url = classloader.getResource( imageName ); 82 if ( url != null ) 83 { 84 ImageIcon icon = new ImageIcon ( url ); 85 return icon; 86 } 87 } 88 catch( Exception e ) 89 { 90 e.printStackTrace(); 91 } 92 throw new IllegalArgumentException ( "Unable to load image: " + imageName ); 93 } 94 95 public JPanel createPanel() 96 { 97 JPanel jpanel1 = new JPanel (); 98 FormLayout formlayout1 = new FormLayout("FILL:7DLU:NONE,RIGHT:MAX(65DLU;DEFAULT):NONE,FILL:3DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:7DLU:NONE","CENTER:9DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:9DLU:NONE"); 99 CellConstraints cc = new CellConstraints(); 100 jpanel1.setLayout(formlayout1); 101 102 _envVarsTextArea.setName("envVarsTextArea"); 103 JScrollPane jscrollpane1 = new JScrollPane (); 104 jscrollpane1.setViewportView(_envVarsTextArea); 105 jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 106 jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 107 jpanel1.add(jscrollpane1,cc.xy(4,2)); 108 109 _envVarsLabel.setName("envVarsLabel"); 110 _envVarsLabel.setText(Messages.getString("setVariables")); 111 jpanel1.add(_envVarsLabel,new CellConstraints(2,2,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); 112 113 addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3 }); 114 return jpanel1; 115 } 116 117 120 protected void initializePanel() 121 { 122 setLayout(new BorderLayout ()); 123 add(createPanel(), BorderLayout.CENTER); 124 } 125 126 127 } 128 | Popular Tags |