content: package com.japisoft.editix.ui.panels.project2;
  
  import java.io.File;
  import javax.swing.event.DocumentEvent;
  import javax.swing.event.DocumentListener;
  import com.japisoft.framework.ui.text.FileTextField;
  import com.japisoft.framework.ui.text.FilePlainDocument;
  
  /**
  This program is available under two licenses : 
  
  1. For non commercial usage : 
  
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
  2. For commercial usage :
  
  You need to get a commercial license for source usage at : 
  
  http://www.editix.com/buy.html
  
  Copyright (c) 2018 Alexandre Brillant - JAPISOFT SARL - http://www.japisoft.com
  
  @author Alexandre Brillant - abrillant@japisoft.com
  @author JAPISOFT SARL - http://www.japisoft.com
  
  */
  public class NewProjectPanel extends javax.swing.JPanel implements DocumentListener {
  
      private static final String DEF_MY_PROJECT = "myProject";
  
  	/** Creates new form NewProjectPanel */
      public NewProjectPanel() {
          initComponents();
          txtProjectLocation.setDirectoryMode( true );
          txtProjectName.setDocument( new FilePlainDocument() );
          txtProjectName.setText( DEF_MY_PROJECT );
      }
  
  	@Override
  	public void addNotify() {
  		super.addNotify();
          txtProjectName.getDocument().addDocumentListener( this );		
  	}
  
  	@Override
  	public void removeNotify() {
  		super.removeNotify();
          txtProjectName.getDocument().removeDocumentListener( this );		
  	}
  
  	public File getProjectLocation() {
  		return new File( txtProjectLocation.getText() );
  	}
  	
      public void changedUpdate(DocumentEvent e) {
      }
  
      public void insertUpdate(DocumentEvent e) {
      	String currentProject = txtProjectLocation.getText();
      	int i = currentProject.lastIndexOf( "/" );
      	if ( i == -1 )
      		i = currentProject.lastIndexOf( "\\" );
      	if ( i > -1 ) {
      		String pathHeader = currentProject.substring( 0, i + 1 );
      		String fullPath = pathHeader + txtProjectName.getText();
      		txtProjectLocation.setText( fullPath );
      	}    	
      }
  
      public void removeUpdate(DocumentEvent e) {
      	insertUpdate( e );
      }
  
      /** 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.
       */
      @SuppressWarnings("unchecked")
      // <editor-fold defaultstate="collapsed" desc="Generated Code">
      private void initComponents() {
  
          lblProjectName = new javax.swing.JLabel();
          txtProjectName = new javax.swing.JTextField( DEF_MY_PROJECT );
          lblProjectLocation = new javax.swing.JLabel();
          txtProjectLocation = new FileTextField( 
          		System.getProperty("user.home" ) + System.getProperty( "file.separator" ) + DEF_MY_PROJECT,
          		(String)null
          );
          
          lblProjectName.setText("Project Name");
          lblProjectName.setName("lblProjectName"); // NOI18N
  
          txtProjectName.setName("txtProjectName"); // NOI18N
  
          lblProjectLocation.setText("Project Location (a directory with all your project files)");
          lblProjectLocation.setName("lblProjectLocation"); // NOI18N
  
          txtProjectLocation.setName("txtProjectLocation"); // NOI18N
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
          this.setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addComponent(txtProjectName, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE)
                      .addComponent(lblProjectName)
                      .addComponent(lblProjectLocation)
                      .addComponent(txtProjectLocation, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE))
                  .addContainerGap())
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(lblProjectName)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addComponent(txtProjectName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addGap(18, 18, 18)
                  .addComponent(lblProjectLocation)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                  .addComponent(txtProjectLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addContainerGap(28, Short.MAX_VALUE))
          );
      }// </editor-fold>
  
      // Variables declaration - do not modify
      private javax.swing.JLabel lblProjectLocation;
      private javax.swing.JLabel lblProjectName;
      private FileTextField txtProjectLocation;
      private javax.swing.JTextField txtProjectName;
      // End of variables declaration
  
  }
  