
/*
 * CropDlg_n.java
 *
 * Created on February 5, 2004, 10:31 AM
 */

package usda.weru.mcrew.gui;

/**
 * This class builds the GUI that holds all the components to make the crop data 
 * visible in different screens categorized in various segments as determined by the
 * GUI builder for end user's ease data manipulation and visualization..
 * @author manmohan
 */
public class CropDlg_n extends javax.swing.JDialog {
    
    
  /**
   * Default constructor for the crop dialog GUI object.
   */
    public CropDlg_n() {
    // this((Frame)null);
        super();
        initComponents();
    }
    
   /**
    * Single argument constructor for the crop dialog GUI object.
    * @param parent The address of the parent component in which this frame sits.
    */
    public CropDlg_n(java.awt.Frame parent) {
        super(parent);
        initComponents();
    }
    
    /**
     * Single argument constructor for the crop dialog GUI object.
     * @param sTitle The title of the frame in which the crop dialog sits.
     */
    public CropDlg_n(java.lang.String title) {
    this();
    setTitle(title);
    }
    
    
    /** 
     * 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.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        JP_main = new javax.swing.JPanel();
        JTP_main = new javax.swing.JTabbedPane();
        JP_parameters = new javax.swing.JPanel();
        JP_cropData = new javax.swing.JPanel();
        JP_param = new javax.swing.JScrollPane();
        JP_toolbar = new javax.swing.JPanel();
        JTB_main = new javax.swing.JToolBar();
        JB_saveAs = new javax.swing.JButton();
        JB_help = new javax.swing.JButton();
        JB_cancel = new javax.swing.JButton();
        JB_close = new javax.swing.JButton();
        JP_specs = new javax.swing.JPanel();
        JLabel1 = new javax.swing.JLabel();
        JTF_cropName = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Crop Drill-down: Displays crop parameters");
        setResizable(false);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                CropDlgN_ComponentResized(evt);
            }
        });
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });
        getContentPane().setLayout(null);

        JP_main.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        JP_main.setLayout(null);

        JTP_main.setToolTipText("CropDrill:drilldown");

        JP_parameters.setToolTipText("CropDrill:drilldown");
        JP_parameters.setFont(new java.awt.Font("Dialog", 1, 12));
        JP_parameters.setLayout(null);

        JP_cropData.setToolTipText("CropDrill:drilldown");
        JP_cropData.setLayout(new java.awt.BorderLayout());

        JP_param.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        JP_param.setToolTipText("CropDrill:drilldown");
        JP_cropData.add(JP_param, java.awt.BorderLayout.CENTER);

        JP_parameters.add(JP_cropData);
        JP_cropData.setBounds(3, 5, 630, 335);

        JTP_main.addTab("Parameters", JP_parameters);

        JP_main.add(JTP_main);
        JTP_main.setBounds(5, 85, 645, 375);

        JP_toolbar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        JP_toolbar.setToolTipText("Weps:toolbar");
        JP_toolbar.setLayout(null);

        JTB_main.setToolTipText("Weps:toolbar");

        JB_saveAs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/usda/weru/resources/save.gif"))); // NOI18N
        JB_saveAs.setToolTipText("CropDrill:save");
        JB_saveAs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_saveAs_ActionPerformed(evt);
            }
        });
        JTB_main.add(JB_saveAs);

        JB_help.setIcon(new javax.swing.ImageIcon(getClass().getResource("/usda/weru/resources/help.gif"))); // NOI18N
        JB_help.setToolTipText("Toolbar:popuphelp");
        JB_help.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBHelp_ActionPerformed(evt);
            }
        });
        JTB_main.add(JB_help);

        JB_cancel.setFont(new java.awt.Font("MS Sans Serif", 1, 11)); // NOI18N
        JB_cancel.setText("Cancel");
        JB_cancel.setToolTipText("CropDrill:cancel");
        JB_cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_cancel_ActionPerformed(evt);
            }
        });
        JTB_main.add(JB_cancel);

        JB_close.setFont(new java.awt.Font("MS Sans Serif", 1, 11)); // NOI18N
        JB_close.setIcon(new javax.swing.ImageIcon(getClass().getResource("/usda/weru/resources/close.gif"))); // NOI18N
        JB_close.setToolTipText("CropDrill:close");
        JB_close.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBClose_ActionPerformed(evt);
            }
        });
        JTB_main.add(JB_close);

        JP_toolbar.add(JTB_main);
        JTB_main.setBounds(5, 5, 270, 30);

        JP_main.add(JP_toolbar);
        JP_toolbar.setBounds(5, 5, 645, 40);

        JP_specs.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        JP_specs.setToolTipText("CropDrill:cropname");
        JP_specs.setLayout(null);

        JLabel1.setFont(new java.awt.Font("MS Sans Serif", 1, 11));
        JLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        JLabel1.setText("Crop Name :");
        JLabel1.setToolTipText("CropDrill:cropname");
        JP_specs.add(JLabel1);
        JLabel1.setBounds(5, 5, 70, 20);

        JTF_cropName.setEditable(false);
        JTF_cropName.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        JTF_cropName.setText("Crop Name");
        JTF_cropName.setToolTipText("CropDrill:cropname");
        JP_specs.add(JTF_cropName);
        JTF_cropName.setBounds(80, 5, 560, 20);

        JP_main.add(JP_specs);
        JP_specs.setBounds(5, 50, 645, 30);

        getContentPane().add(JP_main);
        JP_main.setBounds(10, 10, 660, 480);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-685)/2, (screenSize.height-550)/2, 685, 550);
    }// </editor-fold>//GEN-END:initComponents

    private void JBClose_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBClose_ActionPerformed
        JBClose_actionPerformed(evt);
    }//GEN-LAST:event_JBClose_ActionPerformed

    private void JBHelp_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBHelp_ActionPerformed
        JBHelp_actionPerformed(evt);
    }//GEN-LAST:event_JBHelp_ActionPerformed

    private void CropDlgN_ComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_CropDlgN_ComponentResized
        // Add your handling code here:
        CropDlgN_componentResized(evt);
    }//GEN-LAST:event_CropDlgN_ComponentResized

    private void JB_saveAs_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_saveAs_ActionPerformed
        // Add your handling code here:
        SaveAsJButton_actionPerformed(evt);
}//GEN-LAST:event_JB_saveAs_ActionPerformed

    private void JB_cancel_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_cancel_ActionPerformed
        // Add your handling code here:
        CancelButton_actionPerformed(evt);
}//GEN-LAST:event_JB_cancel_ActionPerformed
   
   /**  
    * This method is called when a SaveAs button on the crop dialog is pressed
    * so that the data could be saved in a new file.
    * @param evt The event generated when the SaveAs button is pressed.
    */
    public void SaveAsJButton_actionPerformed(java.awt.event.ActionEvent evt) {
        // Add your handling code here:
    }

    /**  
    * This method is called when a cancel button on the crop dialog is pressed
    * and any modifications to the data on the screen need not be saved.
    * @param evt The event generated when the cancel button is pressed.
    */
    public void CancelButton_actionPerformed(java.awt.event.ActionEvent evt) {
        // Add your handling code here:
    }
    
    /**  
    * This method is called when the crop dialog is to be closed by hitting the 
    * close button in the tool bar.
    * @param evt The event generated when the cancel button is pressed.
    */
    public void JBClose_actionPerformed(java.awt.event.ActionEvent evt) {
    }

    /**  
    * This method is called when help button from tool bar on the crop dialog is pressed
    * for any help related to the crop dialog components are needed.
    * @param evt The event generated when the help button is pressed.
    */
   public void JBHelp_actionPerformed(java.awt.event.ActionEvent evt) {
    }
    /** 
    * This method is called when the crop dialog is to be closed by hitting the 
    * "Red X" button of the window.
    * @param evt The event generated when the " Red X " button on the window is hit. 
    */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
       closeWindow_actionPerformed(evt);
    }//GEN-LAST:event_closeDialog
    
    /** 
    * This method is called when the crop dialog is to be closed by hitting the 
    * "Red X" button of the window.
    * @param evt The event generated when the " Red X " button on the window is hit. 
    */
    public void closeWindow_actionPerformed(java.awt.event.WindowEvent evt) {
       // Actual implementation will be in cropDlg class
    }

    /**  
    * This method is called when the screen is resized and the components sitting 
    * in the container are to be re-arranged so they are sitting correctly adjecent
    * to each other and evenly spaced.
    * @param evt The event generated when the frame is resized.
    */
    public void CropDlgN_componentResized(java.awt.event.ComponentEvent evt) {
        // Add your handling code here:
    }
    
    /**
     * This method is used if this dialog is rum as an independent application.
     * @param args These are the command line arguments passed to themain method.
     */
    public static void main(String args[]) {
        new CropDlg_n(new javax.swing.JFrame()).setVisible(true);
    }

    /**
     * This method notifies when the window or frame is resized and the components need to be
     * re-arranged so they are evenly spaced relative to each other.
     */
    public void addNotify() {
        // Record the size of the window prior to calling parents addNotify.
	//Dimension d = getSize();
        super.addNotify();
        
        if (fComponentsAdjusted)
		return;

		// Adjust components according to the insets
    /*          Insets ins = getInsets();
		setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height);
		Component components[] = getContentPane().initComponents();
		for (int i = 0; i < components.length; i++)
		{
			Point p = components[i].getLocation();
			p.translate(ins.left, ins.top);
			components[i].setLocation(p);
		}*/
	fComponentsAdjusted = true;
    }    
    
    /**
     * Sets the visibility status of the crop dialog frame whne instantiated.
     * @param b True, makes the dialog visible else false.
     */    
    public void setVisible(boolean b){
        if(b){
            setLocation(50, 50);
        }
        super.setVisible(b);
	}
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton JB_cancel;
    public javax.swing.JButton JB_close;
    public javax.swing.JButton JB_help;
    public javax.swing.JButton JB_saveAs;
    public javax.swing.JLabel JLabel1;
    public javax.swing.JPanel JP_cropData;
    public javax.swing.JPanel JP_main;
    public javax.swing.JScrollPane JP_param;
    public javax.swing.JPanel JP_parameters;
    public javax.swing.JPanel JP_specs;
    public javax.swing.JPanel JP_toolbar;
    public javax.swing.JToolBar JTB_main;
    public javax.swing.JTextField JTF_cropName;
    public javax.swing.JTabbedPane JTP_main;
    // End of variables declaration//GEN-END:variables
    // Used for addNotify check.
    public boolean fComponentsAdjusted = false;
}
