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

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

class MyDialog  extends JDialog 
{

	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;
	
	private	JLabel lbl1;
	private	JLabel lbl2;
	private	JLabel lbl3;
	
	private JTable table1;
	
	DefaultTableModel model;
	
	public MyDialog(JFrame f, boolean modal) 
	{
		
		super(f, modal);
		       
		init();
		
		Point loc = f.getLocation();
		setLocation(loc.x+1250,loc.y+1250);
		/*
		model = new DefaultTableModel();
		table1.setModel(model);
        model.addColumn("Id");
        model.addColumn("First Name");
        model.addColumn("Last Name");
        model.addColumn("Company Name");
*/
		
		// MyDialog
		//setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		
		
		// Label
		//JLabel label = new JLabel("ThaiCreate.Com Version 1.0");
		//label.setBounds(86, 37, 175, 29);
		//getContentPane().add(label);	
		
		
		
	}

	
	private void init()
	{
 		
		setResizable( false );
	  	setBounds(100, 100, 600, 460);
		getContentPane().setLayout(null);
		
		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		setTitle("Test definition ");
		
		String column[]={"ID","NAME","SALARY"};       	
		String data[][]={ {"101","Amit","670000"},    
                {"102","Jai","780000"},    
                {"101","Sachin","700000"}};    
	  
		
		
		
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(34, 24, 525, 189);
		getContentPane().add(scrollPane);

		JTable jtable_test =new JTable(data,column);
		scrollPane.setViewportView(jtable_test );
		
		/*******************/			
		
		lbl1 = new JLabel("aaaa :");
		lbl1.setBounds(36, 255, 45, 14);
		getContentPane().add(lbl1);
		
		JLabel lbl2 = new JLabel("bbbb :");
		lbl2.setBounds(36, 289, 45, 14);
		getContentPane().add(lbl2);
		
		textField_1 = new JTextField();
		textField_1.setBounds(90, 252, 86, 20);
		getContentPane().add(textField_1);
		textField_1.setColumns(10);
		
		textField_2 = new JTextField();
		textField_2.setColumns(10);
		textField_2.setBounds(90, 286, 86, 20);
		getContentPane().add(textField_2);
		
		textField_3 = new JTextField();
		textField_3.setColumns(10);
		textField_3.setBounds(90, 323, 86, 20);
		getContentPane().add(textField_3);
		
		JLabel lbl3 = new JLabel("cccc :");
		lbl3.setBounds(36, 326, 45, 14);
		getContentPane().add(lbl3);
		
		/*******************/			

		 Object[] row = new Object[4];
		
		JButton Btn_add = new JButton("Add");
		Btn_add.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent arg0) 
			{
				System.out.println("Add row");
				//DefaultTableModel model = (DefaultTableModel)jtable_test.getModel();
		        //model.addRow(new Object[]{textField_1.getText(), textField_2.getText(), textField_3.getText()});
		        
		        //model.addRow(new Object[]{ textField_1.getText(), textField_2.getText(),textField_3.getText() });
				
				
				  row[0] = "a";
	                row[1] = "b";
	                row[2] = "c";
	                row[3] = "d";
	                
	             
	                model.addRow(row);
				
		        
			}
		});
		Btn_add.setBounds(441, 252, 89, 23);
		getContentPane().add(Btn_add);
		
		/*******************/
		
		JButton btn_remove = new JButton("Remove");
		btn_remove.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent arg0) 
			{
				System.out.println("Remove");
			}
		});
		
		btn_remove.setBounds(441, 286, 89, 23);
		getContentPane().add(btn_remove);
		
		/*******************/
		
		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 Cancel  \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("Btn Cancel  \n");
				dispose();
			}
		});
		btn_cancel.setBounds(359, 391, 89, 23);
		getContentPane().add(btn_cancel);
		
		
	}	
		
	

		
		
}