/* * PerpectivaTextualVotacao.java * * Created on 29 de Setembro de 2006, 20:58 */ package votacao; import java.awt.Color; import java.util.Observable; import java.util.Observer; /** * * @author 203620 */ public class JPerspectivaTextualVotacao extends javax.swing.JFrame implements Observer { private int votosCand1, votosCand2, votosCand3, votosCand4; private Votacao v; /** Creates new form PerpectivaTextualVotacao */ public JPerspectivaTextualVotacao(Votacao v) { initComponents(); this.v = v; setBounds(50, 300, 300, 300); lblCandidato1.setForeground(Color.red); lblCandidato2.setForeground(Color.green); lblCandidato3.setForeground(Color.pink); lblCandidato4.setForeground(Color.blue); } public void update(Observable o, Object arg) { //v.atualizaQtdVotos(votosCand1, votosCand2, votosCand3, votosCand4); } /** 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. */ // //GEN-BEGIN:initComponents private void initComponents() { spnCandidato1 = new javax.swing.JSpinner(); spnCandidato2 = new javax.swing.JSpinner(); spnCandidato3 = new javax.swing.JSpinner(); spnCandidato4 = new javax.swing.JSpinner(); lblCandidato1 = new javax.swing.JLabel(); lblCandidato2 = new javax.swing.JLabel(); lblCandidato3 = new javax.swing.JLabel(); lblCandidato4 = new javax.swing.JLabel(); getContentPane().setLayout(null); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); spnCandidato1.setName("spnCandidato4"); spnCandidato1.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { spnCandidato1StateChanged(evt); } }); getContentPane().add(spnCandidato1); spnCandidato1.setBounds(80, 40, 120, 20); spnCandidato2.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { spnCandidato2StateChanged(evt); } }); getContentPane().add(spnCandidato2); spnCandidato2.setBounds(80, 100, 120, 20); spnCandidato3.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { spnCandidato3StateChanged(evt); } }); getContentPane().add(spnCandidato3); spnCandidato3.setBounds(80, 160, 120, 20); spnCandidato4.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { spnCandidato4StateChanged(evt); } }); getContentPane().add(spnCandidato4); spnCandidato4.setBounds(80, 220, 120, 20); lblCandidato1.setText("Candidato 01:"); getContentPane().add(lblCandidato1); lblCandidato1.setBounds(80, 20, 90, 14); lblCandidato2.setText("Candidato 02:"); getContentPane().add(lblCandidato2); lblCandidato2.setBounds(80, 80, 90, 14); lblCandidato3.setText("Candidato 03:"); getContentPane().add(lblCandidato3); lblCandidato3.setBounds(80, 140, 80, 14); lblCandidato4.setText("Candidato 04:"); getContentPane().add(lblCandidato4); lblCandidato4.setBounds(80, 200, 80, 14); pack(); } // //GEN-END:initComponents private void spnCandidato4StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnCandidato4StateChanged System.out.println("Novo valor: " + spnCandidato4.getValue()); votosCand4 = Integer.parseInt(String.valueOf(spnCandidato4.getValue())); v.setQtdVotos4(votosCand4); }//GEN-LAST:event_spnCandidato4StateChanged private void spnCandidato3StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnCandidato3StateChanged System.out.println("Novo valor: " + spnCandidato3.getValue()); votosCand3 = Integer.parseInt(String.valueOf(spnCandidato3.getValue())); v.setQtdVotos3(votosCand3); }//GEN-LAST:event_spnCandidato3StateChanged private void spnCandidato2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnCandidato2StateChanged System.out.println("Novo valor: " + spnCandidato2.getValue()); votosCand2 = Integer.parseInt(String.valueOf(spnCandidato2.getValue())); v.setQtdVotos2(votosCand2); }//GEN-LAST:event_spnCandidato2StateChanged private void spnCandidato1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnCandidato1StateChanged System.out.println("Novo valor: " + spnCandidato1.getValue()); votosCand1 = Integer.parseInt(String.valueOf(spnCandidato1.getValue())); v.setQtdVotos1(votosCand1); }//GEN-LAST:event_spnCandidato1StateChanged // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel lblCandidato1; private javax.swing.JLabel lblCandidato2; private javax.swing.JLabel lblCandidato3; private javax.swing.JLabel lblCandidato4; private javax.swing.JSpinner spnCandidato1; private javax.swing.JSpinner spnCandidato2; private javax.swing.JSpinner spnCandidato3; private javax.swing.JSpinner spnCandidato4; // End of variables declaration//GEN-END:variables }