import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;

class TextDialog extends JDialog 
{

		public String text_saisie;
		public String text_previous;
		public String btn_clicked;

		private ClasseTransfert trans = new ClasseTransfert();
		
		public TextDialog() 
		{
		}
			
		public TextDialog(String textdata) 
		{
			setBounds(100, 100, 296, 300);
			setTitle("zone de saisie");
			setLocationRelativeTo(null);
			getContentPane().setLayout(null);
			
			
			int rows = 5;
			int cols = 30;
			
			final JTextArea textArea = new JTextArea();
			textArea.setBounds(10,30, 200,200);  
			
			// charge le text
			textArea.setText( textdata );
			
			// pour le cancel on restaure la data originale avant toute modif
			String originale_textdata = textdata;
			
			textArea.setLineWrap(true);
			textArea.setWrapStyleWord(true);
			
			getContentPane().add(textArea);
			
			btn_clicked = "sdqsfdfsqsqdOK";
			
			// Button OK
			JButton btnOK = new JButton("OK");
			btnOK.addActionListener(new ActionListener() 
			{
				public void actionPerformed(ActionEvent e) 
				{
					//text_previous = text_saisie;
					//btn_clicked = "sdqsfdfsqsqdOK";
					
					trans.set_Btn_clicked("OK");
					
					text_saisie = textArea.getText();
					dispose();
				}
			});
			btnOK.setBounds(70, 250, 78, 23);
			getContentPane().add(btnOK);
			
			// Button Cancel
			JButton btnCancel = new JButton("Cancel");
			btnCancel.addActionListener(new ActionListener() 
			{
				public void actionPerformed(ActionEvent e) 
				{
					//btn_clicked = "CANCEL";
					text_saisie = originale_textdata; // textArea.getText();
					dispose();
				}
			});
			
			btnCancel.setBounds(158, 250, 74, 23);
			getContentPane().add(btnCancel);
			
		}
		

		/*public void setText(String val)
		{
			text_saisie = val;
		}
		*/
		public String getText()
		{
			return text_saisie;       
		}

		public String get_btn_clicked()
		{
			return btn_clicked;       
		}
	}