private void jbExcluirActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jbExcluirActionPerformed try { System.out.println("Excluindo veiculo: " + jList1.getSelectedIndex()); ListaVeiculos.remover(jList1.getSelectedIndex()); Mensagem.informacao("Veículo Excluído", "Exclusão de Cadastro"); jList1.updateUI(); } catch (Exception e) { System.out.println("Erro: " + e); Mensagem.erro("Erro ao excluir Cadastro", "Erro"); } } // GEN-LAST:event_jbExcluirActionPerformed
/** * 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() { jScrollPane1 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList<>(); jbExcluir = new javax.swing.JButton(); setClosable(true); setTitle("Consultar Veiculos"); jList1.setModel(ListaVeiculos.getLista()); jScrollPane1.setViewportView(jList1); jbExcluir.setText("Excluir"); jbExcluir.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbExcluirActionPerformed(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() .addComponent( jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 497, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent( jbExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(34, Short.MAX_VALUE))); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addComponent(jbExcluir) .addGap(0, 0, Short.MAX_VALUE)) .addComponent( jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE)) .addContainerGap())); pack(); } // </editor-fold>//GEN-END:initComponents
/** Creates new form ConsultaVeiculos */ public ConsultaVeiculos() { initComponents(); jList1.setModel(ListaVeiculos.getLista()); }