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.JCheckBox ; 13 import javax.swing.JLabel ; 14 import javax.swing.JPanel ; 15 import javax.swing.JRadioButton ; 16 import javax.swing.JScrollPane ; 17 import javax.swing.JTextArea ; 18 19 public abstract class HeaderForm extends JPanel 20 { 21 protected final JLabel _headerTypeLabel = new JLabel (); 22 protected final JRadioButton _guiHeaderRadio = new JRadioButton (); 23 protected final ButtonGroup _headerButtonGroup = new ButtonGroup (); 24 protected final JRadioButton _consoleHeaderRadio = new JRadioButton (); 25 protected final JTextArea _headerObjectsTextArea = new JTextArea (); 26 protected final JTextArea _libsTextArea = new JTextArea (); 27 protected final JCheckBox _headerObjectsCheck = new JCheckBox (); 28 protected final JCheckBox _libsCheck = new JCheckBox (); 29 protected final TitledSeparator _linkerOptionsSeparator = new TitledSeparator(); 30 31 34 public HeaderForm() 35 { 36 initializePanel(); 37 } 38 39 45 void addFillComponents( Container panel, int[] cols, int[] rows ) 46 { 47 Dimension filler = new Dimension (10,10); 48 49 boolean filled_cell_11 = false; 50 CellConstraints cc = new CellConstraints(); 51 if ( cols.length > 0 && rows.length > 0 ) 52 { 53 if ( cols[0] == 1 && rows[0] == 1 ) 54 { 55 56 panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); 57 filled_cell_11 = true; 58 } 59 } 60 61 for( int index = 0; index < cols.length; index++ ) 62 { 63 if ( cols[index] == 1 && filled_cell_11 ) 64 { 65 continue; 66 } 67 panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); 68 } 69 70 for( int index = 0; index < rows.length; index++ ) 71 { 72 if ( rows[index] == 1 && filled_cell_11 ) 73 { 74 continue; 75 } 76 panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); 77 } 78 79 } 80 81 87 public ImageIcon loadImage( String imageName ) 88 { 89 try 90 { 91 ClassLoader classloader = getClass().getClassLoader(); 92 java.net.URL url = classloader.getResource( imageName ); 93 if ( url != null ) 94 { 95 ImageIcon icon = new ImageIcon ( url ); 96 return icon; 97 } 98 } 99 catch( Exception e ) 100 { 101 e.printStackTrace(); 102 } 103 throw new IllegalArgumentException ( "Unable to load image: " + imageName ); 104 } 105 106 public JPanel createPanel() 107 { 108 JPanel jpanel1 = new JPanel (); 109 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:DEFAULT:GROW(1.0),FILL:7DLU:NONE","CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,FILL:DEFAULT:GROW(0.2),CENTER:3DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:9DLU:NONE"); 110 CellConstraints cc = new CellConstraints(); 111 jpanel1.setLayout(formlayout1); 112 113 _headerTypeLabel.setName("headerTypeLabel"); 114 _headerTypeLabel.setText(Messages.getString("headerType")); 115 jpanel1.add(_headerTypeLabel,cc.xy(2,2)); 116 117 _guiHeaderRadio.setActionCommand("GUI"); 118 _guiHeaderRadio.setName("guiHeaderRadio"); 119 _guiHeaderRadio.setText(Messages.getString("gui")); 120 _headerButtonGroup.add(_guiHeaderRadio); 121 jpanel1.add(_guiHeaderRadio,cc.xy(4,2)); 122 123 _consoleHeaderRadio.setActionCommand("Console"); 124 _consoleHeaderRadio.setName("consoleHeaderRadio"); 125 _consoleHeaderRadio.setText(Messages.getString("console")); 126 _headerButtonGroup.add(_consoleHeaderRadio); 127 jpanel1.add(_consoleHeaderRadio,cc.xy(6,2)); 128 129 _headerObjectsTextArea.setName("headerObjectsTextArea"); 130 JScrollPane jscrollpane1 = new JScrollPane (); 131 jscrollpane1.setViewportView(_headerObjectsTextArea); 132 jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 133 jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 134 jpanel1.add(jscrollpane1,cc.xywh(4,6,4,1)); 135 136 _libsTextArea.setName("libsTextArea"); 137 JScrollPane jscrollpane2 = new JScrollPane (); 138 jscrollpane2.setViewportView(_libsTextArea); 139 jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 140 jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 141 jpanel1.add(jscrollpane2,cc.xywh(4,8,4,1)); 142 143 _headerObjectsCheck.setActionCommand("Object files"); 144 _headerObjectsCheck.setName("headerObjectsCheck"); 145 _headerObjectsCheck.setText(Messages.getString("objectFiles")); 146 jpanel1.add(_headerObjectsCheck,new CellConstraints(2,6,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); 147 148 _libsCheck.setActionCommand("w32api"); 149 _libsCheck.setName("libsCheck"); 150 _libsCheck.setText(Messages.getString("libs")); 151 jpanel1.add(_libsCheck,new CellConstraints(2,8,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); 152 153 _linkerOptionsSeparator.setName("linkerOptionsSeparator"); 154 _linkerOptionsSeparator.setText(Messages.getString("linkerOptions")); 155 jpanel1.add(_linkerOptionsSeparator,cc.xywh(2,4,6,1)); 156 157 addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8 },new int[]{ 1,2,3,4,5,6,7,8,9 }); 158 return jpanel1; 159 } 160 161 164 protected void initializePanel() 165 { 166 setLayout(new BorderLayout ()); 167 add(createPanel(), BorderLayout.CENTER); 168 } 169 170 171 } 172 | Popular Tags |