KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > autoupdate > IncompleteDialog


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.autoupdate;
21
22 import java.awt.Font JavaDoc;
23 import javax.swing.*;
24 import org.openide.DialogDescriptor;
25 import org.openide.DialogDisplayer;
26 import org.openide.util.NbBundle;
27
28 class IncompleteDialog extends javax.swing.JPanel JavaDoc {
29
30     static final int STOP = 0;
31     static final int CANCEL = 1;
32     /** Result of the dialog */
33     private static int result = CANCEL;
34
35     private javax.swing.JLabel JavaDoc titleLabel;
36     private javax.swing.JTextArea JavaDoc textArea;
37     private javax.swing.JLabel JavaDoc iconLabel;
38
39     /** Creates new form ConnectingDialog */
40     public IncompleteDialog() {
41         initComponents();
42         initAccessibility();
43         setPreferredSize(new java.awt.Dimension JavaDoc(350,120));
44     }
45
46     /** This method is called from within the constructor to
47      * initialize the form.
48      */

49     private void initComponents() {
50         iconLabel = new javax.swing.JLabel JavaDoc();
51         titleLabel = new javax.swing.JLabel JavaDoc();
52         textArea = new javax.swing.JTextArea JavaDoc();
53         setLayout(new java.awt.GridBagLayout JavaDoc());
54         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
55
56         iconLabel.setIcon(javax.swing.UIManager.getIcon("OptionPane.warningIcon")); // NOI18N
57
// don't use deriveFont() - see #49973 for details
58
titleLabel.setFont(ResultsPanel.doDeriveFont(titleLabel.getFont(), Font.BOLD));
59         titleLabel.setForeground(java.awt.Color.black);
60         titleLabel.setText(getBundle("CTL_Incomplete_titleLabel"));
61
62         textArea.setFont(new Font JavaDoc ("Dialog", Font.PLAIN, textArea.getFont().getSize()));
63         textArea.setBackground(titleLabel.getBackground ());
64         textArea.setDisabledTextColor(java.awt.Color.black);
65         textArea.setLineWrap(true);
66         textArea.setWrapStyleWord(true);
67         textArea.setEnabled(false);
68         textArea.setText(getBundle("CTL_Incomplete_textLabel"));
69
70         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
71         gridBagConstraints.gridheight = 0;
72         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 18, 0, 0);
73         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
74         add(iconLabel, gridBagConstraints);
75
76         gridBagConstraints.gridx = 1;
77         gridBagConstraints.gridy = 0;
78         gridBagConstraints.gridheight = 1;
79         gridBagConstraints.gridwidth = 0;
80         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 12, 0, 18);
81         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
82         gridBagConstraints.weighty = 0.0;
83         add(titleLabel, gridBagConstraints);
84
85         gridBagConstraints.gridx = 1;
86         gridBagConstraints.gridy = 1;
87         gridBagConstraints.gridwidth = 0;
88         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 0, 18);
89         gridBagConstraints.weightx = 1.0;
90         gridBagConstraints.weighty = 1.0;
91         add(textArea, gridBagConstraints);
92     }
93
94     private void initAccessibility(){
95         getAccessibleContext().setAccessibleDescription(getBundle( "ACSD_Incomplete_Dlg" ) );
96     }
97         
98     private static DialogDescriptor createDialog() {
99
100         final JButton stopButton = new JButton(getBundle( "CTL_Incomplete_Stop" ) );
101         final JButton cancelButton = new JButton(getBundle( "CTL_Incomplete_Cancel" ) );
102         result = CANCEL;
103
104         DialogDescriptor dd;
105         dd = new DialogDescriptor(
106                  new IncompleteDialog(),
107                  getBundle( "CTL_Incomplete_Title" ),
108                  true, // Modal
109
new Object JavaDoc [] {
110                      stopButton,
111                      cancelButton
112                  }, // Option list
113
stopButton, // Default
114
DialogDescriptor.DEFAULT_ALIGN, // Align
115
null, //new HelpCtx ( IncompleteDialog.class ),// Help
116
new java.awt.event.ActionListener JavaDoc() {
117                       public void actionPerformed( java.awt.event.ActionEvent JavaDoc evt ) {
118                           if ( evt.getSource() == stopButton )
119                               result = STOP;
120                           else if ( evt.getSource() == cancelButton )
121                               result = CANCEL;
122                       }
123                  });
124
125         dd.setClosingOptions( null );
126
127         return dd;
128     }
129
130     static int showDialog() {
131         DialogDescriptor dd = createDialog();
132         java.awt.Dialog JavaDoc dialog = DialogDisplayer.getDefault().createDialog( dd );
133         dialog.setVisible (true);
134         dialog.dispose();
135
136         return result;
137     }
138     
139     private static String JavaDoc getBundle( String JavaDoc key ) {
140         return NbBundle.getMessage( IncompleteDialog.class, key );
141     }
142 }
143
Popular Tags