KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > actions > InitPanel


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.core.actions;
21
22 import java.awt.CardLayout JavaDoc;
23 import java.awt.Color JavaDoc;
24 import java.awt.Dimension JavaDoc;
25 import javax.swing.JLabel JavaDoc;
26 import javax.swing.JPanel JavaDoc;
27 import javax.swing.SwingConstants JavaDoc;
28 import javax.swing.UIManager JavaDoc;
29 import org.openide.util.AsyncGUIJob;
30 import org.openide.util.NbBundle;
31 import org.openide.util.Utilities;
32
33 /**
34  * @author Radek Matous
35  */

36 public class InitPanel extends JPanel JavaDoc implements AsyncGUIJob {
37
38     private javax.swing.JLabel JavaDoc initComponent;
39     private OptionsAction.OptionsPanel oPanel;
40     private static InitPanel defInstance;
41
42     static InitPanel getDefault(OptionsAction.OptionsPanel oPanel) {
43         if (defInstance == null) {
44             defInstance = new InitPanel(oPanel);
45         }
46         return defInstance;
47     }
48
49     private InitPanel(OptionsAction.OptionsPanel oPanel) {
50         super();
51         this.oPanel = oPanel;
52         initComponents();
53     }
54
55     protected void initComponents() {
56         if (!oPanel.isPrepared()) {
57             initComponent = new JLabel JavaDoc(NbBundle.getMessage(InitPanel.class, "LBL_computing")); // NOI18N
58
initComponent.setPreferredSize(new Dimension JavaDoc(850, 450));
59             // avoid flicking ?
60
Color JavaDoc c = UIManager.getColor("Tree.background"); // NOI18N
61
if (c == null) {
62                 //GTK 1.4.2 will return null for Tree.background
63
c = Color.WHITE;
64             }
65             initComponent.setBackground(c); // NOI18N
66
initComponent.setHorizontalAlignment(SwingConstants.CENTER);
67             initComponent.setOpaque(true);
68             
69             CardLayout JavaDoc card = new CardLayout JavaDoc();
70             setLayout(card);
71             add(initComponent, "init"); // NOI18N
72
card.show(this, "init"); // NOI18N
73
Utilities.attachInitJob(this, this);
74         } else {
75             finished();
76         }
77     }
78     
79     public void construct() {
80         oPanel.prepareNodes();
81     }
82
83     public void finished() {
84         //initComponent.setBackground((Color) javax.swing.UIManager.getDefaults().get("Tree.background")); // NOI18N
85
add(oPanel, "ready"); // NOI18N
86
CardLayout JavaDoc card = (CardLayout JavaDoc) getLayout();
87         card.show(this, "ready"); // NOI18N
88
oPanel.requestFocus(); // #44487
89
}
90 }
91
Popular Tags