1 19 20 package org.netbeans.core.actions; 21 22 import java.awt.CardLayout ; 23 import java.awt.Color ; 24 import java.awt.Dimension ; 25 import javax.swing.JLabel ; 26 import javax.swing.JPanel ; 27 import javax.swing.SwingConstants ; 28 import javax.swing.UIManager ; 29 import org.openide.util.AsyncGUIJob; 30 import org.openide.util.NbBundle; 31 import org.openide.util.Utilities; 32 33 36 public class InitPanel extends JPanel implements AsyncGUIJob { 37 38 private javax.swing.JLabel 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 (NbBundle.getMessage(InitPanel.class, "LBL_computing")); initComponent.setPreferredSize(new Dimension (850, 450)); 59 Color c = UIManager.getColor("Tree.background"); if (c == null) { 62 c = Color.WHITE; 64 } 65 initComponent.setBackground(c); initComponent.setHorizontalAlignment(SwingConstants.CENTER); 67 initComponent.setOpaque(true); 68 69 CardLayout card = new CardLayout (); 70 setLayout(card); 71 add(initComponent, "init"); card.show(this, "init"); 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 add(oPanel, "ready"); CardLayout card = (CardLayout ) getLayout(); 87 card.show(this, "ready"); oPanel.requestFocus(); } 90 } 91 | Popular Tags |