1 19 20 package org.netbeans.modules.versioning.system.cvss; 21 22 import java.util.*; 23 import javax.swing.JComponent ; 24 import javax.swing.JLabel ; 25 import javax.swing.JTextArea ; 26 27 33 class CommandReport extends javax.swing.JPanel { 34 35 private final String text; 36 37 public CommandReport(String message, List messages) { 38 StringBuffer errorReport = new StringBuffer (); 39 for (Iterator i = messages.iterator(); i.hasNext();) { 40 errorReport.append(i.next()); 41 errorReport.append('\n'); } 43 text = errorReport.toString(); 44 45 initComponents(); 46 47 JComponent msg = createCenterComponent(); 48 jScrollPane1.setViewportView(msg); 49 jLabel1.setText(message); 50 } 51 52 private JComponent createCenterComponent() { 53 if (text.startsWith("<html") || text.startsWith("<HTML")) { JLabel msg = new JLabel (text); 55 return msg; 56 } else { 57 JTextArea msg = new JTextArea (); 58 msg.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.inactiveBackground")); msg.setColumns(40); 60 msg.setEditable(false); 61 msg.setRows(10); 62 msg.setMargin(new java.awt.Insets (4, 4, 0, 0)); 63 msg.setText(text); 64 return msg; 65 } 66 } 67 68 73 private void initComponents() { 75 jLabel1 = new javax.swing.JLabel (); 76 jScrollPane1 = new javax.swing.JScrollPane (); 77 78 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 79 this.setLayout(layout); 80 layout.setHorizontalGroup( 81 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 82 .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() 83 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 84 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE) 85 .add(jLabel1)) 86 .addContainerGap()) 87 ); 88 layout.setVerticalGroup( 89 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 90 .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() 91 .addContainerGap() 92 .add(jLabel1) 93 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 94 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE)) 95 ); 96 } 97 99 100 private javax.swing.JLabel jLabel1; 102 private javax.swing.JScrollPane jScrollPane1; 103 105 } 106 | Popular Tags |