import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;

public class ClasseCor extends JFrame implements ActionListener
{
    JButton bt_Amarelo, bt_Azul, bt_Vermelho, bt_Verde;
    public ClasseCor ()
    {
        getContentPane().setLayout(new FlowLayout());
        getContentPane().add(bt_Amarelo = new JButton("AMARELO"));
        getContentPane().add(bt_Azul = new JButton("AZUL"));
        getContentPane().add(bt_Vermelho = new JButton("VERMELHO"));
        getContentPane().add(bt_Verde = new JButton("VERDE"));
        System.out.println("ANDRE APARECIDO DA SILVA");
        getContentPane().setBackground(Color.blue);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setSize(500, 400);
        setVisible(true);
        setTitle("OXNAR- Prof. Andre Aparecido da Silva");
        setResizable(false);
        this.setLocationRelativeTo(null); //Abre o JFrame
        bt_Amarelo.addActionListener(this);
        bt_Azul.addActionListener(this);
        bt_Vermelho.addActionListener(this);
        bt_Verde.addActionListener(this);

    }
    public void actionPerformed (ActionEvent e)
    {
        if(e.getSource()==bt_Amarelo)
        {
            getContentPane().setBackground(Color.yellow);
            Metodo_Inativa_botoes(bt_Amarelo);
        }

        if(e.getSource()==bt_Azul)
        {
            getContentPane().setBackground(Color.blue);
            Metodo_Inativa_botoes(bt_Azul);
        }
        if(e.getSource()==bt_Vermelho)
        {
            getContentPane().setBackground(Color.red);
            Metodo_Inativa_botoes(bt_Vermelho);
        }
        if(e.getSource()==bt_Verde)
        {
            getContentPane().setBackground(Color.green);
            Metodo_Inativa_botoes(bt_Verde);
        }
    }
    public void Metodo_Inativa_botoes(JButton botao)
    {
        bt_Verde.setEnabled(true);
        bt_Vermelho.setEnabled(true);
        bt_Amarelo.setEnabled(true);
        bt_Azul.setEnabled(true);
        botao.setEnabled(false);
    }
    public static void main(String[] args)
    {new ClasseCor();}
}
