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.modules.url;


import java.awt.Component;
import javax.swing.event.ChangeListener;
import javax.swing.JPanel;

import org.openide.loaders.TemplateWizard;
import org.openide.WizardDescriptor;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;


/**
 * Panel used as a component for url wizard panel.
 *
 * @author  Peter Zavadsky
 * @see URLWizardPanel
 */
public class URLPanel extends JPanel {

    /** Creates new form URLPanel */
    public URLPanel() {
        initComponents();
        // Accessibility
        this.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(URLPanel.class).getString("ACS_DESC"));
        urlText.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(URLPanel.class).getString("ACS_Field"));
        
        urlLabel.setDisplayedMnemonic(NbBundle.getBundle(URLPanel.class).getString("LBL_URLMnemonic").charAt(0));
        urlLabel.setLabelFor(urlText);
        
        setName(NbBundle.getBundle(URLPanel.class).getString("LBL_SetURL")); // NOI18N
        putClientProperty("WizardPanel_contentSelectedIndex", new Integer(1)); // NOI18N
    }
    

    /** Sets URL string appearing in text field in this panel. */
    public void setURLString(String urlString) {
        if(urlString == null)
            return;
        
        urlText.setText(urlString);
    }

    /** Gets URL string set by user in this panel. */
    public String getURLString() {
        return urlText.getText();
    }
    
    /** Requests focus for text field for setting URL string. Overrides superclass method. */ 
    public void requestFocus() {
        urlText.requestFocus();
        urlText.selectAll();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        java.awt.GridBagConstraints gridBagConstraints;

        urlLabel = new javax.swing.JLabel();
        urlText = new javax.swing.JTextField();

        setLayout(new java.awt.GridBagLayout());

        urlLabel.setText(NbBundle.getBundle(URLPanel.class).getString("LBL_URL"));
        urlLabel.setLabelFor(urlText);
        add(urlLabel, new java.awt.GridBagConstraints());

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
        add(urlText, gridBagConstraints);

    }//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField urlText;
    private javax.swing.JLabel urlLabel;
    // End of variables declaration//GEN-END:variables

    
    /** Wizard panel used as a second wizard panel in URL wizard iterator.
     * @see org.openide.WizardDescriptor.Panel */
    public static class URLWizardPanel implements WizardDescriptor.Panel {

        /** Component used by this wizard panel. */
        private URLPanel component;

        /** Dummy implementation of WizardDescriptor.Panel. */
        public void addChangeListener(ChangeListener l) {}
        
        /** Dummy implementation of WizardDescriptor.Panel. */
        public void removeChangeListener(ChangeListener l) {}

        /** Gets component for this wizard panel. Implements WizardDescriptor.Panel.
         * @return component */
        public Component getComponent() {
            if(component == null) 
                component = new URLPanel();
            
            return component;
        }

        /** Gets help context. Implements WizardDescriptor.Panel. */
        public HelpCtx getHelp() {
            return new HelpCtx(URLPanel.class);
        }

        /** Indicates if the panel is valid, e.g. for enabling next button. 
         * Implements WizardDescriptor.Panel. 
         * @return true */
        public boolean isValid() {
            return true;
        }

        /** Reads settings which is of TemplateWizard instnance. Retrieves the default
         * URL string from url data object template. */
        public void readSettings(Object settings) {
            TemplateWizard wizard = (TemplateWizard)settings;
            ((URLPanel)getComponent()).setURLString(((URLDataObject)wizard.getTemplate()).getURLString());
        }
        
        /** Dummy implementation of WizardDescriptor.Panel. */
        public void storeSettings(Object settings) {}
        
    } // End of class URLWizardPanel.

}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 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.