/*
 * TextInputDialog.java
 *
 * Created on December 19, 2005, 12:56 PM
 */

package usda.weru.util.gui;

import java.awt.Dimension;

/**
 *
 * @author  lrdinuki
 */
public class TextInputDialog_n extends javax.swing.JDialog {
    private static final long serialVersionUID = 1L;
    
    /** Creates new form TextInputDialog
	 * @param parent
	 * @param modal */
    public TextInputDialog_n(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

	/**
	 *
	 */
	public TextInputDialog_n() {
        
    }
    
    /** 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() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        JTA_EditPanel = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        JB_Save = new javax.swing.JButton();
        JB_Cancel = new javax.swing.JButton();

        setTitle("Text Editor");
        setModal(true);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                TextInputDialogComponentResized(evt);
            }
        });

        jPanel1.setLayout(null);

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setPreferredSize(new java.awt.Dimension(500, 300));
        jScrollPane1.setViewportView(JTA_EditPanel);

        jPanel1.add(jScrollPane1);
        jScrollPane1.setBounds(4, 5, 500, 300);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        jPanel2.setPreferredSize(new java.awt.Dimension(145, 35));

        JB_Save.setText("Save");
        JB_Save.setPreferredSize(new java.awt.Dimension(65, 23));
        JB_Save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_SaveActionPerformed(evt);
            }
        });
        jPanel2.add(JB_Save);

        JB_Cancel.setText("Cancel");
        JB_Cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JB_CancelActionPerformed(evt);
            }
        });
        jPanel2.add(JB_Cancel);

        getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void TextInputDialogComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_TextInputDialogComponentResized
        TextInputDialog_ComponentResized(evt);
    }//GEN-LAST:event_TextInputDialogComponentResized

    private void JB_CancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_CancelActionPerformed
        JBCancel_ActionPerformed(evt);
    }//GEN-LAST:event_JB_CancelActionPerformed

    private void JB_SaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_SaveActionPerformed
        JBSave_ActionPerformed(evt);
    }//GEN-LAST:event_JB_SaveActionPerformed
    
    protected void JBCancel_ActionPerformed(java.awt.event.ActionEvent evt) {
    }

	/**
	 *
	 * @param evt
	 */
	protected void JBSave_ActionPerformed(java.awt.event.ActionEvent evt) {
    }

	/**
	 *
	 * @param evt
	 */
	public void TextInputDialog_ComponentResized(java.awt.event.ComponentEvent evt) {
            invalidate();
        Dimension size = evt.getComponent().getSize();
        //Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        //Setting the width of the frame to a fixed size
        if(size.getWidth() < 510 ){
            size.width = 510;
        }
        if(size.getHeight() < 330 ){
            size.height = 330;
        }
        
        this.setSize(size);
        size.height -= 45;
        size.width  -= 5;
        JTA_EditPanel.setSize(size);
        size.height -= 30;
        size.width  -= 10;
        jScrollPane1.setSize(size);
        //size.height -= 10;
        //JP_main.setSize(size);
        invalidate();
        repaint();
        
}

    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new TextInputDialog_n(new javax.swing.JFrame(), true).setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    protected javax.swing.JButton JB_Cancel;
    protected javax.swing.JButton JB_Save;
    protected javax.swing.JTextArea JTA_EditPanel;
    protected javax.swing.JPanel jPanel1;
    protected javax.swing.JPanel jPanel2;
    protected javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
    
}
