/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * FrmUF.java * * Created on 03/09/2010, 20:01:34 */ package boundary; import control.ControladoraUF; import java.sql.SQLException; import java.text.ParseException; import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import util.ConexaoException; import util.MinhaException; /** * * @author Rodrigo Martins */ public class FrmUFAlterar extends javax.swing.JDialog { ControladoraUF cadastroUF; Vector linha; /** Creates new form FrmUF */ public FrmUFAlterar(Vector linha){ initComponents(); this.linha = linha; this.setLocationRelativeTo(null); this.setModal(true); this.cadastroUF = new ControladoraUF(); this.jTFSiglaUf.setText(linha.get(0).toString()); this.jTFNomeUF.setText(linha.get(1).toString()); } /** 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() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jTFSiglaUf = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); jTFNomeUF = new javax.swing.JTextField(); jBOk = new javax.swing.JButton(); jBLimpar = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("SCC - Cadastro UF"); setResizable(false); jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); jLabel1.setText("Sigla UF"); jTFSiglaUf.setEnabled(false); jLabel2.setText("Nome UF"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jTFSiglaUf, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jTFNomeUF, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTFNomeUF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTFSiglaUf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jBOk.setText("OK"); jBOk.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBOkActionPerformed(evt); } }); jBLimpar.setText("Limpar"); jBLimpar.setMaximumSize(new java.awt.Dimension(80, 22)); jBLimpar.setMinimumSize(new java.awt.Dimension(80, 22)); jBLimpar.setPreferredSize(new java.awt.Dimension(80, 22)); jBLimpar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBLimparActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(jBOk, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jBLimpar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jBOk) .addComponent(jBLimpar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jBOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBOkActionPerformed // TODO add your handling code here: if (!this.jTFSiglaUf.getText().isEmpty()) { if (!this.jTFNomeUF.getText().isEmpty()) { Vector alterarUF = new Vector(); alterarUF.addElement(this.jTFSiglaUf.getText()); alterarUF.addElement(this.jTFNomeUF.getText()); try { this.cadastroUF.alterarUF(alterarUF); this.jTFNomeUF.setText(""); this.jTFSiglaUf.setText(""); this.dispose(); } catch (ParseException ex) { Logger.getLogger(FrmUFAlterar.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(FrmUFAlterar.class.getName()).log(Level.SEVERE, null, ex); } catch (MinhaException ex) { Logger.getLogger(FrmUFAlterar.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { String sql = ex.getSQLState(); if (sql.equals("23503")){ JOptionPane.showMessageDialog(null, "Não é possivel apagar este regesitro!\n" + "Ele esta sendo utilizado por outro dado!","Atenção" , JOptionPane.WARNING_MESSAGE); } Logger.getLogger(FrmUFAlterar.class.getName()).log(Level.SEVERE, null, ex); } catch (ConexaoException ex) { Logger.getLogger(FrmUFAlterar.class.getName()).log(Level.SEVERE, null, ex); } }else JOptionPane.showMessageDialog(null, "É necessário O Nome da UF!","Atenção" , JOptionPane.WARNING_MESSAGE); } }//GEN-LAST:event_jBOkActionPerformed private void jBLimparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBLimparActionPerformed // TODO add your handling code here: this.jTFNomeUF.setText(""); this.jTFSiglaUf.setText(""); }//GEN-LAST:event_jBLimparActionPerformed /** * @param args the command line arguments public static void main(String args[]) throws UnsupportedLookAndFeelException { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException ex) { Logger.getLogger(FrmCadastroOficina.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { Logger.getLogger(FrmCadastroOficina.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(FrmCadastroOficina.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedLookAndFeelException ex) { Logger.getLogger(FrmCadastroOficina.class.getName()).log(Level.SEVERE, null, ex); } java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new FrmUF().setVisible(true); } }); } */ // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jBLimpar; private javax.swing.JButton jBOk; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; private javax.swing.JTextField jTFNomeUF; private javax.swing.JTextField jTFSiglaUf; // End of variables declaration//GEN-END:variables }