KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > javadoc > ConfPanel


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.tasklist.javadoc;
21
22 import java.awt.*;
23 import javax.swing.*;
24 import org.openide.util.NbBundle;
25
26 import javax.swing.text.*;
27
28
29 /**
30  * A confirmation panel for suggestion fixes etc.
31  *
32  * @author Tor Norbye
33  */

34 public class ConfPanel extends javax.swing.JPanel JavaDoc {
35
36     private static final long serialVersionUID = 1;
37
38     /** Creates new form ConfPanel */
39     public ConfPanel(String JavaDoc beforeDesc, String JavaDoc beforeContents,
40                      String JavaDoc afterDesc, String JavaDoc afterContents,
41                      String JavaDoc filename, int line) {
42         initComponents();
43         
44         mainLabel.setText(beforeDesc);
45         beforeLabel.setText(beforeContents);
46         if (afterDesc != null) {
47             changedToLabel.setText(afterDesc);
48         } else {
49             changedToLabel.setVisible(false);
50         }
51         if (afterContents != null) {
52             afterLabel.setText(afterContents);
53         } else {
54             afterLabel.setVisible(false);
55         }
56         fileLabel.setText(filename);
57         if (line >= 0) {
58             lineLabel.setText(Integer.toString(line));
59         } else {
60             lineLabel.setVisible(false);
61             jLabel5.setVisible(false);
62         }
63         Dimension d = jScrollPane1.getPreferredSize();
64         int width = (int)d.getWidth();
65         int height = (int)d.getHeight();
66         if ((width > 400) || (height > 200)) {
67             if (width > 400) {
68                 width = 400;
69             }
70             if (height > 200) {
71                 height = 200;
72             }
73             jScrollPane1.setPreferredSize(new Dimension(width, height));
74         }
75         d = jScrollPane2.getPreferredSize();
76         width = (int)d.getWidth();
77         height = (int)d.getHeight();
78         if ((width > 400) || (height > 200)) {
79             if (width > 400) {
80                 width = 400;
81             }
82             if (height > 200) {
83                 height = 200;
84             }
85             jScrollPane2.setPreferredSize(new Dimension(width, height));
86         }
87     }
88     
89     /** This method is called from within the constructor to
90      * initialize the form.
91      * WARNING: Do NOT modify this code. The content of this method is
92      * always regenerated by the Form Editor.
93      */

94     private void initComponents() {//GEN-BEGIN:initComponents
95
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
96
97         mainLabel = new javax.swing.JLabel JavaDoc();
98         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
99         beforeLabel = new javax.swing.JLabel JavaDoc();
100         changedToLabel = new javax.swing.JLabel JavaDoc();
101         jScrollPane2 = new javax.swing.JScrollPane JavaDoc();
102         afterLabel = new javax.swing.JLabel JavaDoc();
103         jLabel3 = new javax.swing.JLabel JavaDoc();
104         fileLabel = new javax.swing.JLabel JavaDoc();
105         jLabel5 = new javax.swing.JLabel JavaDoc();
106         lineLabel = new javax.swing.JLabel JavaDoc();
107
108         setLayout(new java.awt.GridBagLayout JavaDoc());
109
110         setPreferredSize(new java.awt.Dimension JavaDoc(600, 400));
111         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
112         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
113         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
114         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
115         add(mainLabel, gridBagConstraints);
116
117         beforeLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);
118         beforeLabel.setBackground((java.awt.Color JavaDoc) javax.swing.UIManager.getDefaults().get("TextField.background"));
119         beforeLabel.setOpaque(true);
120         jScrollPane1.setViewportView(beforeLabel);
121
122         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
123         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
124         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
125         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
126         gridBagConstraints.weightx = 1.0;
127         gridBagConstraints.weighty = 1.0;
128         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
129         add(jScrollPane1, gridBagConstraints);
130
131         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
132         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
133         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
134         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
135         add(changedToLabel, gridBagConstraints);
136
137         afterLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);
138         afterLabel.setBackground((java.awt.Color JavaDoc) javax.swing.UIManager.getDefaults().get("TextField.background"));
139         afterLabel.setOpaque(true);
140         jScrollPane2.setViewportView(afterLabel);
141
142         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
143         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
144         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
145         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
146         gridBagConstraints.weightx = 1.0;
147         gridBagConstraints.weighty = 1.0;
148         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
149         add(jScrollPane2, gridBagConstraints);
150
151         jLabel3.setText(NbBundle.getMessage(ConfPanel.class, "File")); // NOI18N();
152
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
153         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
154         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 12, 0, 11);
155         add(jLabel3, gridBagConstraints);
156
157         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
158         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
159         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
160         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 0, 11);
161         add(fileLabel, gridBagConstraints);
162
163         jLabel5.setText(NbBundle.getMessage(ConfPanel.class, "Line")); // NOI18N();
164
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
165         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
166         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 0, 11);
167         add(jLabel5, gridBagConstraints);
168
169         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
170         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
171         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
172         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 11);
173         add(lineLabel, gridBagConstraints);
174
175     }//GEN-END:initComponents
176

177     
178     // Variables declaration - do not modify//GEN-BEGIN:variables
179
private javax.swing.JLabel JavaDoc mainLabel;
180     private javax.swing.JLabel JavaDoc fileLabel;
181     private javax.swing.JLabel JavaDoc changedToLabel;
182     private javax.swing.JLabel JavaDoc beforeLabel;
183     private javax.swing.JLabel JavaDoc afterLabel;
184     private javax.swing.JLabel JavaDoc jLabel5;
185     private javax.swing.JLabel JavaDoc jLabel3;
186     private javax.swing.JScrollPane JavaDoc jScrollPane2;
187     private javax.swing.JScrollPane JavaDoc jScrollPane1;
188     private javax.swing.JLabel JavaDoc lineLabel;
189     // End of variables declaration//GEN-END:variables
190

191 }
192
Popular Tags