Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Interface;
- import Connection.AutorDAO;
- import Model.Autor;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.List;
- import javax.swing.JOptionPane;
- import javax.swing.table.DefaultTableModel;
- /**
- *
- * @author IrlanJR
- */
- public class jifLista extends javax.swing.JInternalFrame {
- DefaultTableModel tbLogs = new DefaultTableModel(null, new String[]{"Cรณdigo", "Nome", "Nascimento"});
- AutorDAO autorDAO = new AutorDAO();
- public jifLista() {
- initComponents();
- jTbTeste.setModel(tbLogs);
- }
- /**
- * 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">
- private void initComponents() {
- jScrollPane1 = new javax.swing.JScrollPane();
- jTbTeste = new javax.swing.JTable();
- jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- tfPesquisar = new javax.swing.JTextField();
- setClosable(true);
- setResizable(true);
- try {
- setSelected(true);
- } catch (java.beans.PropertyVetoException e1) {
- e1.printStackTrace();
- }
- setVisible(true);
- addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
- public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
- }
- public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
- }
- public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
- }
- public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
- }
- public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
- }
- public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
- }
- public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
- formInternalFrameOpened(evt);
- }
- });
- jTbTeste.setModel(new javax.swing.table.DefaultTableModel(
- new Object [][] {
- {},
- {},
- {},
- {}
- },
- new String [] {
- }
- ));
- jScrollPane1.setViewportView(jTbTeste);
- jButton1.setText("Selecionar");
- jButton2.setText("Cancelar");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(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)
- .addGroup(layout.createSequentialGroup()
- .addComponent(tfPesquisar)
- .addContainerGap())
- .addGroup(layout.createSequentialGroup()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 359, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGap(12, 12, 12))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
- .addContainerGap())))))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(tfPesquisar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
- .addGap(22, 22, 22)
- .addComponent(jButton1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton2)))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>
- private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
- preencherTabela();
- }
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- }
- // Variables declaration - do not modify
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JScrollPane jScrollPane1;
- public javax.swing.JTable jTbTeste;
- private javax.swing.JTextField tfPesquisar;
- // End of variables declaration
- public void exibirAutores(List<Autor> list){
- list = autorDAO.acharTodos();
- while (tbLogs.getRowCount() > 0) {
- tbLogs.removeRow(0);
- }
- try {
- String[] linhas = new String[]{null, null, null};
- for (int i = 0; i < list.size(); i++) {
- tbLogs.addRow(linhas);
- tbLogs.setValueAt(list.get(i).getCod(), i, 0);
- tbLogs.setValueAt(list.get(i).getNome(), i, 1);
- tbLogs.setValueAt(list.get(i).getDataNasc(), i, 2);
- }
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "Erro ao listar pessoas!; " + e);
- }
- }
- public void preencherTabela(){
- List<Autor> list = autorDAO.acharTodos();
- exibirAutores(list);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement