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.JCheckBox ; 11 import javax.swing.JLabel ; 12 import javax.swing.JPanel ; 13 import javax.swing.JScrollPane ; 14 import javax.swing.JTextArea ; 15 16 public abstract class MessagesForm extends JPanel 17 { 18 protected final JTextArea _startupErrTextArea = new JTextArea (); 19 protected final JTextArea _bundledJreErrTextArea = new JTextArea (); 20 protected final JTextArea _jreVersionErrTextArea = new JTextArea (); 21 protected final JTextArea _launcherErrTextArea = new JTextArea (); 22 protected final JCheckBox _messagesCheck = new JCheckBox (); 23 24 27 public MessagesForm() 28 { 29 initializePanel(); 30 } 31 32 38 void addFillComponents( Container panel, int[] cols, int[] rows ) 39 { 40 Dimension filler = new Dimension (10,10); 41 42 boolean filled_cell_11 = false; 43 CellConstraints cc = new CellConstraints(); 44 if ( cols.length > 0 && rows.length > 0 ) 45 { 46 if ( cols[0] == 1 && rows[0] == 1 ) 47 { 48 49 panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); 50 filled_cell_11 = true; 51 } 52 } 53 54 for( int index = 0; index < cols.length; index++ ) 55 { 56 if ( cols[index] == 1 && filled_cell_11 ) 57 { 58 continue; 59 } 60 panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); 61 } 62 63 for( int index = 0; index < rows.length; index++ ) 64 { 65 if ( rows[index] == 1 && filled_cell_11 ) 66 { 67 continue; 68 } 69 panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); 70 } 71 72 } 73 74 80 public ImageIcon loadImage( String imageName ) 81 { 82 try 83 { 84 ClassLoader classloader = getClass().getClassLoader(); 85 java.net.URL url = classloader.getResource( imageName ); 86 if ( url != null ) 87 { 88 ImageIcon icon = new ImageIcon ( url ); 89 return icon; 90 } 91 } 92 catch( Exception e ) 93 { 94 e.printStackTrace(); 95 } 96 throw new IllegalArgumentException ( "Unable to load image: " + imageName ); 97 } 98 99 public JPanel createPanel() 100 { 101 JPanel jpanel1 = new JPanel (); 102 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,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:3DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:3DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:3DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:9DLU:NONE"); 103 CellConstraints cc = new CellConstraints(); 104 jpanel1.setLayout(formlayout1); 105 106 _startupErrTextArea.setName("startupErrTextArea"); 107 JScrollPane jscrollpane1 = new JScrollPane (); 108 jscrollpane1.setViewportView(_startupErrTextArea); 109 jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 110 jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 111 jpanel1.add(jscrollpane1,cc.xy(4,4)); 112 113 _bundledJreErrTextArea.setName("bundledJreErrTextArea"); 114 JScrollPane jscrollpane2 = new JScrollPane (); 115 jscrollpane2.setViewportView(_bundledJreErrTextArea); 116 jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 117 jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 118 jpanel1.add(jscrollpane2,cc.xy(4,6)); 119 120 _jreVersionErrTextArea.setName("jreVersionErrTextArea"); 121 _jreVersionErrTextArea.setToolTipText(Messages.getString("jreVersionErrTip")); 122 JScrollPane jscrollpane3 = new JScrollPane (); 123 jscrollpane3.setViewportView(_jreVersionErrTextArea); 124 jscrollpane3.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 125 jscrollpane3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 126 jpanel1.add(jscrollpane3,cc.xy(4,8)); 127 128 _launcherErrTextArea.setName("launcherErrTextArea"); 129 JScrollPane jscrollpane4 = new JScrollPane (); 130 jscrollpane4.setViewportView(_launcherErrTextArea); 131 jscrollpane4.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 132 jscrollpane4.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 133 jpanel1.add(jscrollpane4,cc.xy(4,10)); 134 135 JLabel jlabel1 = new JLabel (); 136 jlabel1.setText(Messages.getString("startupErr")); 137 jpanel1.add(jlabel1,new CellConstraints(2,4,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); 138 139 JLabel jlabel2 = new JLabel (); 140 jlabel2.setText(Messages.getString("bundledJreErr")); 141 jpanel1.add(jlabel2,new CellConstraints(2,6,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); 142 143 JLabel jlabel3 = new JLabel (); 144 jlabel3.setText(Messages.getString("jreVersionErr")); 145 jpanel1.add(jlabel3,new CellConstraints(2,8,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); 146 147 JLabel jlabel4 = new JLabel (); 148 jlabel4.setText(Messages.getString("launcherErr")); 149 jpanel1.add(jlabel4,new CellConstraints(2,10,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); 150 151 _messagesCheck.setActionCommand("Add version information"); 152 _messagesCheck.setName("messagesCheck"); 153 _messagesCheck.setText(Messages.getString("addMessages")); 154 jpanel1.add(_messagesCheck,cc.xy(4,2)); 155 156 addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11 }); 157 return jpanel1; 158 } 159 160 163 protected void initializePanel() 164 { 165 setLayout(new BorderLayout ()); 166 add(createPanel(), BorderLayout.CENTER); 167 } 168 169 170 } 171 | Popular Tags |