/*
 * PainelCores.java
 *
 * Created on 28 de Novembro de 2008, 23:44
 */

package ambienteGrafico.componentes;

import java.awt.Paint;
import javax.swing.ImageIcon;
import javax.swing.JFrame;

/**
 *
 * @author  Marília
 */
public class PainelCores extends MeuPainel {

    private MeuPainel painelPai = null;

    /** Creates new form PainelCores */
    public PainelCores(MeuPainel painelPai) {
        super.mudarLookAndFeel();
        initComponents();
        this.painelPai = painelPai;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bt_AzulEscuro = new MyJButton(); ;
        bt_Amarelo = new MyJButton(); ;
        bt_Vermelho = new MyJButton(); ;
        bt_VerdeClaro = new MyJButton(); ;
        bt_VerdeEscuro = new MyJButton(); ;
        bt_Rosa = new MyJButton(); ;
        bt_CorAtual = new MyJButton();

        setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Painel de Cores", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N
        setPreferredSize(new java.awt.Dimension(200, 100));
        setLayout(null);

        bt_AzulEscuro.setBackground(new java.awt.Color(0, 0, 204));
        bt_AzulEscuro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_AzulEscuroActionPerformed(evt);
            }
        });
        add(bt_AzulEscuro);
        bt_AzulEscuro.setBounds(10, 50, 30, 30);

        bt_Amarelo.setBackground(new java.awt.Color(0, 0, 255));
        bt_Amarelo.setForeground(new java.awt.Color(0, 0, 255));
        bt_Amarelo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_AmareloActionPerformed(evt);
            }
        });
        add(bt_Amarelo);
        bt_Amarelo.setBounds(40, 20, 30, 30);

        bt_Vermelho.setBackground(new java.awt.Color(255, 0, 0));
        bt_Vermelho.setForeground(new java.awt.Color(255, 0, 0));
        bt_Vermelho.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_VermelhoActionPerformed(evt);
            }
        });
        add(bt_Vermelho);
        bt_Vermelho.setBounds(10, 20, 30, 30);

        bt_VerdeClaro.setBackground(new java.awt.Color(51, 255, 102));
        bt_VerdeClaro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_VerdeClaroActionPerformed(evt);
            }
        });
        add(bt_VerdeClaro);
        bt_VerdeClaro.setBounds(40, 50, 30, 30);

        bt_VerdeEscuro.setBackground(new java.awt.Color(0, 255, 0));
        bt_VerdeEscuro.setForeground(new java.awt.Color(0, 255, 0));
        bt_VerdeEscuro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_VerdeEscuroActionPerformed(evt);
            }
        });
        add(bt_VerdeEscuro);
        bt_VerdeEscuro.setBounds(70, 20, 30, 30);

        bt_Rosa.setBackground(new java.awt.Color(255, 0, 255));
        bt_Rosa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_RosaActionPerformed(evt);
            }
        });
        add(bt_Rosa);
        bt_Rosa.setBounds(70, 50, 30, 30);

        bt_CorAtual.setBorderPainted(false);
        bt_CorAtual.setOpaque(false);
        add(bt_CorAtual);
        bt_CorAtual.setBounds(100, 30, 33, 40);
    }// </editor-fold>//GEN-END:initComponents

private void bt_AmareloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_AmareloActionPerformed
    bt_CorAtual.setBackground(bt_Amarelo.getBackground());
    bt_CorAtual.setIcon(bt_Amarelo.getIcon());
    mudarCorAlvoFerramentaInserirAlvo();
}//GEN-LAST:event_bt_AmareloActionPerformed

private void bt_VermelhoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_VermelhoActionPerformed
    bt_CorAtual.setBackground(bt_Vermelho.getBackground());
    bt_CorAtual.setIcon(bt_Vermelho.getIcon());
    mudarCorAlvoFerramentaInserirAlvo();
}//GEN-LAST:event_bt_VermelhoActionPerformed

private void bt_VerdeEscuroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_VerdeEscuroActionPerformed
    bt_CorAtual.setBackground(bt_VerdeEscuro.getBackground());
    bt_CorAtual.setIcon(bt_VerdeEscuro.getIcon());
    mudarCorAlvoFerramentaInserirAlvo();
}//GEN-LAST:event_bt_VerdeEscuroActionPerformed

private void bt_RosaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_RosaActionPerformed
    bt_CorAtual.setBackground(bt_Rosa.getBackground());
    bt_CorAtual.setIcon(bt_Rosa.getIcon());
    mudarCorAlvoFerramentaInserirAlvo();
}//GEN-LAST:event_bt_RosaActionPerformed

private void bt_AzulEscuroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_AzulEscuroActionPerformed
    bt_CorAtual.setBackground(bt_AzulEscuro.getBackground());
    bt_CorAtual.setIcon(bt_AzulEscuro.getIcon());
    mudarCorAlvoFerramentaInserirAlvo();
}//GEN-LAST:event_bt_AzulEscuroActionPerformed

private void bt_VerdeClaroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_VerdeClaroActionPerformed
    bt_CorAtual.setBackground(bt_VerdeClaro.getBackground());
    bt_CorAtual.setIcon(bt_VerdeClaro.getIcon());
    mudarCorAlvoFerramentaInserirAlvo();
}//GEN-LAST:event_bt_VerdeClaroActionPerformed

    public Paint getCorSelecionada(){
        return bt_CorAtual.getBackground();
    }

    private void mudarCorAlvoFerramentaInserirAlvo(){
        //muda a cor do alvo na ferramenta de inserção de alvos
        if(this.painelPai instanceof PainelFerramentaAlvos){

            PainelFerramentaAlvos painelFerramentaAlvos = (PainelFerramentaAlvos)painelPai;
            painelFerramentaAlvos.getFerramentaInserirAlvo().setCorTexturaAlvo(bt_CorAtual.getBackground());

        }

    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
       
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                JFrame frame =  new JFrame();
                
                frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
                PainelCores panel = new PainelCores(null);
                panel.setVisible(true);

                frame.setContentPane(panel);
                frame.setVisible(true);
                frame.pack();
            }
        });
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bt_Amarelo;
    private javax.swing.JButton bt_AzulEscuro;
    private javax.swing.JButton bt_CorAtual;
    private javax.swing.JButton bt_Rosa;
    private javax.swing.JButton bt_VerdeClaro;
    private javax.swing.JButton bt_VerdeEscuro;
    private javax.swing.JButton bt_Vermelho;
    // End of variables declaration//GEN-END:variables

}
