|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.welcome; import org.openide.util.NbBundle; import org.openide.*; import org.openide.windows.*; import java.io.*; import java.awt.*; import java.lang.reflect.Method; import javax.swing.*; import javax.accessibility.*; import org.openide.ErrorManager; /** * The welcome screen. * @author Richard Gregor */ class WelcomeComponent extends TopComponent{ static final long serialVersionUID=6021472310161712674L; private static WelcomeComponent component = null; private JComponent panel; private boolean initialized = false; private WelcomeComponent(){ setLayout(new BorderLayout()); setName(NbBundle.getMessage(WelcomeComponent.class, "LBL_Tab_Title")); //NOI18N panel = null; initialized = false; } protected String preferredID(){ return "WelcomeComponent"; //NOI18N } /** * #38900 - lazy addition of GUI components */ private void doInitialize() { initAccessibility(); try{ panel =(JComponent)Class.forName(NbBundle.getMessage(WelcomeComponent.class,"CLASS_content_panel")).newInstance(); }catch(Exception e){ ErrorManager.getDefault().notify(e); } if(panel == null) return; JScrollPane scroll = new JScrollPane(panel); // no border, borders are managed by window system scroll.setBorder(BorderFactory.createEmptyBorder()); scroll.setViewportBorder(BorderFactory.createEmptyBorder()); add(scroll); scroll.getHorizontalScrollBar().setValue(0); scroll.getVerticalScrollBar().setValue(0); setFocusable(true); } /* Singleton accessor. As WelcomeComponent is persistent singleton this * accessor makes sure that WelcomeComponent is deserialized by window system. * Uses known unique TopComponent ID "Welcome" to get WelcomeComponent instance * from window system. "Welcome" is name of settings file defined in module layer. */ public static WelcomeComponent findComp() { if (component == null) { TopComponent tc = WindowManager.getDefault().findTopComponent("Welcome"); // NOI18N if (tc != null) { if (tc instanceof WelcomeComponent) { component = (WelcomeComponent) tc; } else { //Incorrect settings file? IllegalStateException exc = new IllegalStateException ("Incorrect settings file. Unexpected class returned." // NOI18N + " Expected:" + WelcomeComponent.class.getName() // NOI18N + " Returned:" + tc.getClass().getName()); // NOI18N ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, exc); //Fallback to accessor reserved for window system. WelcomeComponent.createComp(); } } else { //WelcomeComponent cannot be deserialized //Fallback to accessor reserved for window system. WelcomeComponent.createComp(); } } return component; } /* Singleton accessor reserved for window system ONLY. Used by window system to create * WelcomeComponent instance from settings file when method is given. Use |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.