alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

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

package org.netbeans.core.ui;

import java.beans.*;
import java.util.ArrayList;

import org.openide.ErrorManager;
import org.openide.WizardDescriptor;
import org.openide.awt.HtmlBrowser;

import org.netbeans.core.IDESettings;

/** Setup wizard panel for selecting web browser
 *
 * @author  gtichy
 */
public class WebBrowserPanel extends javax.swing.JPanel 
                             implements org.openide.WizardDescriptor.FinishPanel,
                                        PropertyChangeListener {

    java.util.ResourceBundle bundle = org.openide.util.NbBundle.getBundle ("org/netbeans/core/ui/Bundle"); // NOI18N

    /** Creates new form WebBrowserPanel */
    public WebBrowserPanel () {
        initComponents();
        browserLabel.setDisplayedMnemonic (bundle.getString ("CTL_BrowserLabel_mnemonic").charAt (0));
        browserLabel.setLabelFor (browserComboBox);
        helpTextArea.setFont (javax.swing.UIManager.getFont ("Label.font")); // NOI18N
        helpTextArea.setDisabledTextColor (javax.swing.UIManager.getColor ("Label.foreground")); // NOI18N
        setName (bundle.getString ("LBL_WebBrowserPanelName"));
        
        // fill the combo box
        try {
            IDESettings settings = (IDESettings)IDESettings.findObject (IDESettings.class, true);
            editor = PropertyEditorManager.findEditor (org.openide.awt.HtmlBrowser.Factory.class);
            editor.setValue (settings.getWWWBrowser ());
            String [] tags = editor.getTags ();
            for (int j=0; jtrue if the user has entered satisfactory information
    */
    public boolean isValid () {
        return true;
    }

    public void storeSettings(java.lang.Object obj) {
    }
    
    public void readSettings(java.lang.Object settings) {
        if (settings instanceof WizardDescriptor) {
            ((WizardDescriptor)settings).addPropertyChangeListener(this);
        }
    }
    
    public void addChangeListener(javax.swing.event.ChangeListener l) {
        if (!changeListeners.contains(l)) {
            changeListeners.add(l);
        }
    }

    public void removeChangeListener(javax.swing.event.ChangeListener l) {
        changeListeners.remove(l);
    }
    
    /** Handling of property changes in node structure and setup wizard descriptor
     */
    public void propertyChange(PropertyChangeEvent evt) {
        if ((evt.getSource() instanceof WizardDescriptor) 
            && (WizardDescriptor.PROP_VALUE.equals(evt.getPropertyName()))) {
                
            WizardDescriptor wd = (WizardDescriptor)evt.getSource();
            if (wd.getValue() == wd.FINISH_OPTION) {
                wd.removePropertyChangeListener(this);
                if (editor != null) {
                    try {
                        Object o = browserComboBox.getSelectedItem ();
                        if (o instanceof String && (o != null)) {
                            IDESettings settings = (IDESettings)IDESettings.findObject (IDESettings.class, true);
                            editor.setAsText ((String)o);
                            settings.setWWWBrowser ((HtmlBrowser.Factory)editor.getValue ());
                        }
                    }
                    catch (Exception ex) {
                        ErrorManager.getDefault ().notify (ex);
                    }
                }
            }
        }
    }
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.