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