
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Rectangle;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.border.TitledBorder;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JSeparator;

public class titi extends JDialog 
{

	private Color current;
	private JTextField text_start_state;
	private JTextField txt_end_state;
	private JTextField text_name;
	private JTextField text_equation;
	
	private boolean OK_close_Jdialog = false;

  Integer lEntier = new Integer(0);
  String leNom;

  public titi(JFrame f, boolean modal) 
  {
       super(f, modal);

       // decalage par rapport au frame
       Point location = f.getLocation();
       setLocation(location.x + 250, location.y + 250);

       // fermer la fenetre
       addWindowListener(new java.awt.event.WindowAdapter() 
       {
           public void windowClosing(java.awt.event.WindowEvent e) 
           {
        	   dispose();
           }
       });
       
       //jbInit();
       init();
   
  }

  // envoi les datas
  public void initialise( Object [] o)
  {
      lEntier = (Integer)o[0];
      leNom = (String)o[1];
      //jTextField1.setText(lEntier.toString());
      //jTextField2.setText(leNom);
  }
 
  // retourne les datas
  public Object [] getDonnees()
  {
      return new Object[]{OK_close_Jdialog, lEntier , leNom};

  }

//  public void show_dialog()
//  {
//       setVisible(true);
//  }
  
  
  private void jbInit() //throws Exception 
  {
	  
	  	setBounds(100, 100, 600, 460);
		getContentPane().setLayout(null);
		//{
		//}
	
		JPanel panel = new JPanel();
		
		//setPreferredSize( new Dimension( 640, 480 ) );
		setPreferredSize( new Dimension( 600, 460 ) );
		
		setResizable( false );
	
		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		setTitle("Debug Edit tansistion Properties");
	
		panel.addMouseListener(new MouseAdapter() 
		{
			@Override
			public void mouseClicked(MouseEvent arg0) 
			{
				Color newColor = JColorChooser.showDialog(null, "Choose a color", current);
				panel.setBackground(newColor);
			}
		});
	
	
		panel.setBorder(new LineBorder(new Color(0, 0, 0)));
		panel.setBounds(44, 324, 60, 34);
		getContentPane().add(panel);
	
		JLabel lbl_comments = new JLabel("Comments");
		lbl_comments.setBounds(44, 35, 72, 14);
		getContentPane().add(lbl_comments);

	  
		JLabel lbl_start_state = new JLabel("Start state :");
		lbl_start_state.setBounds(44, 254, 72, 14);
		getContentPane().add(lbl_start_state);
	
		JLabel lbl_end_state = new JLabel("end state :");
		lbl_end_state.setBounds(44, 285, 72, 14);
		getContentPane().add(lbl_end_state);
	
		text_start_state = new JTextField();
		text_start_state.setEditable(false);
		text_start_state.setBounds(113, 251, 86, 20);
		getContentPane().add(text_start_state);
		text_start_state.setColumns(10);
	
		txt_end_state = new JTextField();
		txt_end_state.setEditable(false);
		txt_end_state.setColumns(10);
		txt_end_state.setBounds(113, 282, 86, 20);
		getContentPane().add(txt_end_state);
	
		JSeparator separator = new JSeparator();
		separator.setBounds(1, 384, 600, 2);
		getContentPane().add(separator);
	
		/*****/
		JButton btn_ok = new JButton("OK");
		btn_ok.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent arg0) 
			{
				System.out.println("Btn OK  \n");
				OK_close_Jdialog = true;
				dispose();
			}
		});
		btn_ok.setBounds(135, 391, 89, 23);
		getContentPane().add(btn_ok);

		/*****/
		JButton btn_cancel = new JButton("Cancel");
		btn_cancel.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				System.out.println("Btn Cancel  \n");
				OK_close_Jdialog = false;
				dispose();
			}
		});
		btn_cancel.setBounds(359, 391, 89, 23);
		getContentPane().add(btn_cancel);
	
		/*****/

		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(44, 58, 201, 171);
		getContentPane().add(scrollPane);
	
		JTextArea textArea = new JTextArea();
		scrollPane.setViewportView(textArea);
		textArea.setWrapStyleWord(true);
		textArea.setLineWrap(true);
		textArea.setRows(20);
		textArea.setColumns(40);
		
		JLabel lbl_state_name = new JLabel("Name");
		lbl_state_name.setBounds(292, 64, 65, 14);
		getContentPane().add(lbl_state_name);
		
		JLabel lbl_equation = new JLabel("Equation :");
		lbl_equation.setBounds(292, 97, 65, 14);
		getContentPane().add(lbl_equation);
		
		text_name = new JTextField();
		text_name.setBounds(388, 61, 120, 20);
		getContentPane().add(text_name);
		text_name.setColumns(10);
		
		
		text_name.setText("Blabla");
		
		text_equation = new JTextField();
		text_equation.setBounds(388, 94, 120, 20);
		getContentPane().add(text_equation);
		text_equation.setColumns(10);
   
  }
  
  private void init()
  {
	  	setBounds(100, 100, 600, 460);
		getContentPane().setLayout(null);
		{
		}
	
		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		setTitle("Edit aaaaState Properties");
	
		JLabel lbl_comments = new JLabel("Comments");
		lbl_comments.setBounds(44, 35, 72, 14);
		getContentPane().add(lbl_comments);
	
		JSeparator separator = new JSeparator();
		separator.setBounds(1, 384, 580, 2);
		getContentPane().add(separator);
	
		JButton btn_ok = new JButton("OK");
		btn_ok.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent arg0) 
			{
				System.out.println("OK  \n");
				dispose();
			}
		});
		btn_ok.setBounds(135, 391, 89, 23);
		getContentPane().add(btn_ok);
	
		JButton btn_cancel = new JButton("Cancel");
		btn_cancel.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				System.out.println("Cancel  \n");
				setVisible(false);
			}
		});
		btn_cancel.setBounds(359, 391, 89, 23);
		getContentPane().add(btn_cancel);
		
		JLabel lbl_state_name = new JLabel("X:");
		lbl_state_name.setBounds(44, 64, 24, 14);
		getContentPane().add(lbl_state_name);
		
		JLabel lbl_equation = new JLabel("Y:");
		lbl_equation.setBounds(44, 97, 24, 14);
		getContentPane().add(lbl_equation);
		
		text_name = new JTextField();
		text_name.setBounds(68, 60, 120, 20);
		getContentPane().add(text_name);
		text_name.setColumns(10);
		
		
		text_name.setText("Blabla");
		
		text_equation = new JTextField();
		text_equation.setBounds(68, 93, 120, 20);
		getContentPane().add(text_equation);
		text_equation.setColumns(10);
		
		JCheckBox chk_box_set_text = new JCheckBox("Set text");
		chk_box_set_text.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				
				boolean isSelected = chk_box_set_text.isSelected();
				if(isSelected)
				{
					System.out.println("Manual settings");
				}
				else
				{
					System.out.println("Auto Settings");
				}
			}
		});
		chk_box_set_text.setBounds(38, 127, 97, 23);
		getContentPane().add(chk_box_set_text);
  }
 

}