KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > view > common > CommonMessagePanel


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 /*
21  * CommonMessagePanel.java
22  *
23  * Created on June 9, 2006, 4:59 PM
24  */

25
26 package org.netbeans.modules.xml.wsdl.ui.view.common;
27
28 import java.awt.Color JavaDoc;
29 import java.awt.Graphics JavaDoc;
30
31 import javax.swing.ImageIcon JavaDoc;
32 import javax.swing.UIManager JavaDoc;
33
34 import org.openide.util.Utilities;
35
36 /**
37  *
38  * @author skini
39  */

40 public class CommonMessagePanel extends javax.swing.JPanel JavaDoc {
41     private static Color JavaDoc nbErrorForeground;
42     private static Color JavaDoc nbWarningForeground;
43     private boolean mValidState = false;
44
45     static {//Got this from WizardDescriptor
46
nbErrorForeground = UIManager.getColor("nb.errorForeground"); //NOI18N
47
if (nbErrorForeground == null) {
48             nbErrorForeground = new Color JavaDoc(255, 0, 0); // RGB suggested by jdinga in #65358
49
}
50         nbWarningForeground = UIManager.getColor("nb.errorForeground"); //NOI18N
51
if (nbWarningForeground == null) {
52             nbWarningForeground = new Color JavaDoc(255, 0, 0); // RGB suggested by jdinga in #65358
53
}
54         
55     }
56     /** Creates new form CommonMessagePanel */
57     public CommonMessagePanel() {
58         initComponents();
59     }
60     
61     /** This method is called from within the constructor to
62      * initialize the form.
63      * WARNING: Do NOT modify this code. The content of this method is
64      * always regenerated by the Form Editor.
65      */

66     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
67
private void initComponents() {
68         m_lblMessage = new javax.swing.JLabel JavaDoc();
69
70         m_lblMessage.setLabelFor(this);
71         m_lblMessage.setToolTipText(org.openide.util.NbBundle.getMessage(CommonMessagePanel.class, "CommonMessagePanel.m_lblMessage.toolTipText")); // NOI18N
72
m_lblMessage.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CommonMessagePanel.class, "CommonMessagePanel.m_lblMessage.AccessibleContext.accessibleName")); // NOI18N
73

74         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
75         this.setLayout(layout);
76         layout.setHorizontalGroup(
77             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
78             .add(layout.createSequentialGroup()
79                 .add(m_lblMessage, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
80                 .addContainerGap())
81         );
82         layout.setVerticalGroup(
83             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
84             .add(m_lblMessage)
85         );
86     }// </editor-fold>//GEN-END:initComponents
87
public void setErrorMessage(String JavaDoc errorMsg) {
88         m_lblMessage.setText(errorMsg);
89         m_lblMessage.setForeground (nbErrorForeground);
90         m_lblMessage.repaint();
91         m_lblMessage.setIcon(new ImageIcon JavaDoc(Utilities.loadImage("org/openide/resources/error.gif")));
92         mValidState = false;
93     }
94     
95     public void setWarningMessage(String JavaDoc warningMsg) {
96         m_lblMessage.setText(warningMsg);
97         m_lblMessage.setForeground (nbWarningForeground);
98         m_lblMessage.repaint();
99         m_lblMessage.setIcon(new ImageIcon JavaDoc (Utilities.loadImage ("org/openide/resources/warning.gif")));
100         mValidState = true;
101     }
102     
103     public void setMessage(String JavaDoc msg) {
104         m_lblMessage.setText(msg);
105         m_lblMessage.setIcon(null);
106         mValidState = true;
107     }
108     
109     public boolean isStateValid() {
110         return mValidState;
111     }
112     public void paint(Graphics JavaDoc g) {
113         super.paint(g);
114         //Graphics2D g2d = (Graphics2D)g;
115

116         //g2d.drawLine(0, this.getHeight()-1, this.getWidth(), this.getHeight()-1);
117
}
118     
119     // Variables declaration - do not modify//GEN-BEGIN:variables
120
private javax.swing.JLabel JavaDoc m_lblMessage;
121     // End of variables declaration//GEN-END:variables
122

123 }
124
Popular Tags