/**
 * @(#)Text1.java
 *
 *
 * @author 
 * @version 1.00 2018/3/21
 */
 
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;

public class exercijy extends JFrame implements ActionListener {
		JPanel pnome, pbutton;
		JButton bnext, bclean, bexit;
		JLabel lname;
		int aux= 1;
		
    public exercijy() 
    	{
    		getContentPane().setLayout(new GridLayout(2, 1));
    		getContentPane().add(pnome = new JPanel (new FlowLayout(FlowLayout.CENTER))); 
    		pnome.add(lname = new JLabel("Joao V.Z")); 
    		getContentPane().add(pbutton = new JPanel (new FlowLayout(FlowLayout.CENTER))); 
			pbutton.add(bnext = new JButton ("PROXIMO"));
			pbutton.add(bclean = new JButton ("LIMPAR")); 
			pbutton.add(bexit = new JButton ("SAIR"));  
    	   	pack();
    		setVisible(true); 
    		setResizable(false);
    		bnext.addActionListener(this);
    		 bclean.addActionListener(this); 
    		 bexit.addActionListener(this);
    }
        public  static void main (String args [])
    {
    		new exercijy();
    }
    public void actionPerformed(ActionEvent e)
    {
    	if(e.getSource()==bexit)
    		System.exit(0);
    	if(e.getSource()==bclean)
    		lname.setText("");
    	if(e.getSource()==bnext)
    	{
    		if(aux==1)
    		{
    			   lname.setText("Yuri");
    			   aux = aux +1;
    		}
   

    		else if(aux==2)
    		{
    			   lname.setText("Ana");
    			   lname.setBackground(Color.yellow);
    			   repaint();
    			   aux = aux +1;
    		}   
    		
    		else if(aux==3)
    		{
    			   lname.setText("Leticia"); 
    			   aux = aux +1;
    		}   
    		
    		else if(aux==4)
    		{
    			   lname.setText("joao");
    			   aux = 1;
    		}   
    		
    		
    			
    	}
    		
    }
    
}