import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
//import java.util.*;
//import javax.swing.event.*;

public class LectureJDialog extends JDialog implements KeyListener{// implements ActionListener{ 
	Font police;
	private JScrollPane scroll;
	private JTextBackdrop texteList = new JTextBackdrop(new String());
	//private JButton okBtn=new JButton("OK");
	private JLabel infoLbl=new JLabel("Any Key to quit / Une touche pour quitter");
	
	Monde monde;
	
	public LectureJDialog(Monde world,String tx){
		police=world.getPolice();
		monde=world;
		
		Container c=getContentPane();
		c.setLayout(null);
		
		//retour à ligne automatique
		texteList.setLineWrap(true);
		
		//pas de coupure des mots
		texteList.setWrapStyleWord(true);
		
		texteList.addKeyListener(this);
		
		infoLbl.setFont(police);
		texteList.setFont(police);
		
		
		scroll = new JScrollPane(texteList);
		scroll.setBounds(5,5,280,350);
		c.add(scroll);
		
		//okBtn.setBounds(100,370,70,20);
		//c.add(okBtn);
		//okBtn.addActionListener(this);
		
		infoLbl.setBounds(20,370,250,20);
		c.add(infoLbl);
		
		
		setLocation(200,200);
		setSize(300,450);
		show();
		
		remplir(tx);
		
	}
	
	public void remplir(String txt){
		
		texteList.append(txt+"\n");
		
		//scrolling automatique
		try { 
        texteList.scrollRectToVisible(texteList.modelToView(texteList.getDocument().getLength ())); 
		} catch (javax.swing.text.BadLocationException err) { }
	}
	

	/////////////////////////////////////////////
	public void keyPressed(KeyEvent e){
		//char lettre=e.getKeyChar();
		monde.jeuPan.requestFocus();
		dispose();
	}
	
	public void keyReleased(KeyEvent e){}
	
	public void keyTyped(KeyEvent e){}
	
	
	
	/*
	public void actionPerformed(ActionEvent e){
		Object source=e.getSource();
		if(source==okBtn){
			dispose();	
		}	
		
	}*/
	
}