1 19 20 package org.netbeans.modules.xml.xam.ui.customizer; 21 22 import java.util.Collection ; 23 import javax.swing.ImageIcon ; 24 import javax.swing.JComponent ; 25 import javax.swing.JLabel ; 26 import org.jdesktop.layout.GroupLayout; 27 import org.openide.util.Utilities; 28 29 33 public class MessagePanel extends javax.swing.JPanel implements MessageDisplayer 34 { 35 static final long serialVersionUID = 1L; 36 37 38 public MessagePanel() 39 { 40 initComponents(); 41 } 42 43 48 private void initComponents() 50 { 51 panel = new javax.swing.JPanel (); 52 53 setLayout(new java.awt.BorderLayout ()); 54 55 panel.setLayout(null); 56 57 GroupLayout panelLayout = new GroupLayout(panel); 58 panel.setLayout(panelLayout); 59 panelLayout.setAutocreateGaps(true); 60 panelLayout.setAutocreateContainerGaps(true); 61 GroupLayout.ParallelGroup hGroup = 62 panelLayout.createParallelGroup(); 63 panelLayout.setHorizontalGroup(hGroup); 64 GroupLayout.SequentialGroup vGroup = 65 panelLayout.createSequentialGroup(); 66 panelLayout.setVerticalGroup(vGroup); 67 add(panel, java.awt.BorderLayout.CENTER); 68 69 } 71 public void annotate(String message, MessageDisplayer.Type type) 72 { 73 if(!isVisible()) setVisible(true); 74 JLabel messageLabel = new JLabel (message); 75 switch(type) 76 { 77 case ERROR: 78 messageLabel.setIcon(new ImageIcon (Utilities.loadImage( 79 "org/netbeans/modules/xml/xam/ui/resources/error.gif"))); break; 81 case WARNING: 82 messageLabel.setIcon(new ImageIcon (Utilities.loadImage( 83 "org/netbeans/modules/xml/xam/ui/resources/warning.gif"))); break; 85 case INFO: 86 default: 87 } 88 GroupLayout layout = (GroupLayout)panel.getLayout(); 89 ((GroupLayout.ParallelGroup)layout.getHorizontalGroup()).add(messageLabel); 90 ((GroupLayout.SequentialGroup)layout.getVerticalGroup()).add(messageLabel); 91 } 92 93 public void clear() 94 { 95 remove(panel); 96 initComponents(); 97 setVisible(false); 98 } 99 100 public JComponent getComponent() 101 { 102 return this; 103 } 104 105 106 private javax.swing.JPanel panel; 108 110 } 111 | Popular Tags |