KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xam > ui > customizer > MessagePanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.xam.ui.customizer;
21
22 import java.util.Collection JavaDoc;
23 import javax.swing.ImageIcon JavaDoc;
24 import javax.swing.JComponent JavaDoc;
25 import javax.swing.JLabel JavaDoc;
26 import org.jdesktop.layout.GroupLayout;
27 import org.openide.util.Utilities;
28
29 /**
30  *
31  * @author Ajit Bhate
32  */

33 public class MessagePanel extends javax.swing.JPanel JavaDoc implements MessageDisplayer
34 {
35     static final long serialVersionUID = 1L;
36     
37     /** Creates new form MessagePanel */
38     public MessagePanel()
39     {
40         initComponents();
41     }
42     
43     /** This method is called from within the constructor to
44      * initialize the form.
45      * WARNING: Do NOT modify this code. The content of this method is
46      * always regenerated by the Form Editor.
47      */

48     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
49
private void initComponents()
50     {
51         panel = new javax.swing.JPanel JavaDoc();
52
53         setLayout(new java.awt.BorderLayout JavaDoc());
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     }// </editor-fold>//GEN-END:initComponents
70

71     public void annotate(String JavaDoc message, MessageDisplayer.Type type)
72     {
73         if(!isVisible()) setVisible(true);
74         JLabel JavaDoc messageLabel = new JLabel JavaDoc(message);
75         switch(type)
76         {
77             case ERROR:
78                 messageLabel.setIcon(new ImageIcon JavaDoc(Utilities.loadImage(
79                         "org/netbeans/modules/xml/xam/ui/resources/error.gif"))); // NOI18N
80
break;
81             case WARNING:
82                 messageLabel.setIcon(new ImageIcon JavaDoc(Utilities.loadImage(
83                         "org/netbeans/modules/xml/xam/ui/resources/warning.gif"))); // NOI18N
84
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 JavaDoc getComponent()
101     {
102         return this;
103     }
104     
105     
106     // Variables declaration - do not modify//GEN-BEGIN:variables
107
private javax.swing.JPanel JavaDoc panel;
108     // End of variables declaration//GEN-END:variables
109

110 }
111
Popular Tags