

import javax.swing.*;
import javax.swing.table.DefaultTableModel;

import java.awt.*;  
import java.awt.event.*;
import java.net.URL;


public class Dialog_properties extends JDialog 
{
    
    private JTextArea textArea;
    private String champ_textarea = "";
    private String init_textarea = "";
    
    private static final int TA_ROWS = 20;
    private static final int TA_COLS = 35;

 
    
    public Dialog_properties(JFrame f, boolean modal, String init_textarea) 
	{
    	super(f, modal);
    	
    	this.init_textarea = init_textarea;
    	
        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();
            }
        });
        
        init(); 
    }
    
    
    // recoit les datas
    public void initialise( Object [] o)
    {
    	init_textarea = (String)o[0];
    }
   
    // retourne les datas
    public Object [] getDonnees()
    {
        return new Object[]{champ_textarea};
    }
    
    private void init()
	{
		setTitle("Properties");
    	setResizable( false );

    	//setBounds(100, 100, 600, 460);
		//getContentPane().setLayout(null);
     	
		ImageIcon icon = null;
		icon = createImageIcon("resources/settings.png", "");
		setIconImage( icon.getImage() );
		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		
		setBounds(100, 100, 450, 300);
		setTitle("Properties");
		getContentPane().setLayout(null);
		
		JScrollPane scrollPane = new JScrollPane();
		//scrollPane.setBounds(110, 25, 214, 163);
		
		// 8 char = 60
		// 32 = 240
		// 22 = 180
		
		scrollPane.setBounds(110, 25, 160, 163); 
		
		
		getContentPane().add(scrollPane);
		
		
		
		
		JTextArea textArea = new JTextArea();
		
		//JTextArea textArea = new JTextArea(TA_ROWS, TA_COLS);
		
		textArea.setWrapStyleWord(true);
		textArea.setLineWrap(true);
		textArea.setColumns(20);
		
		scrollPane.setViewportView(textArea);

		JSeparator separator = new JSeparator();
		separator.setBounds(0, 206, 440, 2);
		getContentPane().add(separator);
		
		
		textArea.setText(init_textarea);
		
		JButton btn_ok = new JButton("ON");
		btn_ok.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				champ_textarea = textArea.getText().toString();
				dispose();
			}
		});
		btn_ok.setBounds(172, 228, 89, 23);
		getContentPane().add(btn_ok);
		
	}
	

    public ImageIcon createImageIcon(String path,  String description) 
	{
		URL imgURL = getClass().getResource(path);

		if (imgURL != null)
		{
  			return new ImageIcon(imgURL, description);
		} 
		else 
		{
			System.err.println("Couldn't find file: " + path);
			return null;
		}
	}

  
}