Exemplo de um Jdialog atualizando um jpane que está em um cardlayout

Olá amigos, alguém teria um exemplo para eu focar meus estudos ?

Tipo, tenho a aplicação main, e tenho 3 jpanel,

1 - principal
2 - estado
3 - contatos.

já consegui desabilitar os menus quando eu estou no jpanel estado e contatos, porem este menu está no meu jframe, estou tentando fazer algo parecido so que para atualizar minha jtable que está em um destes jpanel, e não estou conseguindo.

Desde já agradeço a ajuda que este forum (voce membros) que nos ajuda sempre.

Christian

Posta o fonte das suas classes.

Bom dia staroski

Este é meu main que guarda o cardlayout classe Agenda

package view;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class Agenda extends JFrame {
    public static JPanel painelBase;
    public static CardLayout cardLayout;
    public static JMenu mnCadastro;
    public static JMenu mnRelatorio;
    public static JMenu mnAjuda;
    public void initComponents() {
    	
        Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());
        painelBase = new JPanel();
        cardLayout = new CardLayout();
        painelBase.setLayout (cardLayout);
        
        // Adicionando os cards
        jPnl_Contato    panel_Contato    = new jPnl_Contato();
        jPnl_Estado     panel_Estado     = new jPnl_Estado();
        jPnl_Principal  panel_Principal  = new jPnl_Principal();
        
        painelBase.add (panel_Principal, "principal");
        painelBase.add (panel_Contato, "contato");
        painelBase.add (panel_Estado, "estado");

        contentPane.add (painelBase);

        setPreferredSize (new Dimension (1000, 600));
		JMenuBar menuBar = new JMenuBar();
		
		Toolkit tk = Toolkit.getDefaultToolkit();
	    Dimension d = tk.getScreenSize();
	    
	    //Screen width  = d.width
	    //Screen height = d.height
		menuBar.setBounds(1, 1, d.width, 20);
		contentPane.add(menuBar, BorderLayout.NORTH);
		
		mnCadastro = new JMenu();
		mnCadastro.setMnemonic('C');
		mnCadastro.setText("Cadastro");
		menuBar.add(mnCadastro);
		
		JMenuItem mntmContato = new JMenuItem("Contato");
		mntmContato.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
                cardLayout.show (painelBase, "contato");
			}
		});
		mntmContato.setMnemonic('C');
		mnCadastro.add(mntmContato);
		
		mnRelatorio = new JMenu("Relatorio");
		mnRelatorio.setMnemonic('R');
		menuBar.add(mnRelatorio);

		mnAjuda = new JMenu("Ajuda");
		mnAjuda.setMnemonic('A');
		menuBar.add(mnAjuda);

		JMenuItem mntmEstado = new JMenuItem("Estado");
		mntmEstado.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				mnCadastro.setEnabled(false);
				mnRelatorio.setEnabled(false);
				mnAjuda.setEnabled(false);

                cardLayout.show (painelBase, "estado");
			}
		});
		cardLayout.show (painelBase, "principal");
		mntmEstado.setMnemonic('E');
		mnCadastro.add(mntmEstado);
		
		JMenuItem mntmContato_1 = new JMenuItem("Contato");
		mntmContato_1.setMnemonic('C');
		mnRelatorio.add(mntmContato_1);
		
		JMenuItem mntmSobre = new JMenuItem("Sobre");
		mntmSobre.setMnemonic('S');
		mnAjuda.add(mntmSobre);
    }
    public Agenda () {
        super ("Agenda de Contatos");
        initComponents();
    }    
    public static void main(String[] args) {
        Agenda agenda = new Agenda();
        agenda.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        agenda.pack();
		agenda.setLocationRelativeTo(null);
        agenda.setExtendedState(JFrame.MAXIMIZED_BOTH);
		agenda.setVisible (true);
    }
}

classe do painel que tem a tabela para ser atualizada

package view;

import javax.swing.JLabel;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import java.awt.Font;

import model.EstadoDao;
import view.Estado.IncluiEstado;

import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.awt.event.ActionEvent;
import javax.swing.JTable;

import controler.EstadoTableModel;
import javax.swing.ListSelectionModel;

@SuppressWarnings("serial")
public class jPnl_Estado extends JPanel {
	private JTable tblEstado;
	private EstadoTableModel tableModel;
	private JScrollPane rolagem;
	
	public jPnl_Estado() {
	    initComponents();
        rolagem = new JScrollPane(getTblEstado());
        add(rolagem);
        rolagem.setBounds(150, 60, 400, 400);
	}
	private JTable getTblEstado() {
        if (tblEstado == null) {
            tblEstado = new JTable();
            tblEstado.setModel(getTableModel());
    	    Ajusta_Tamanho_Coluna();
        }
        return tblEstado;
    }
	private EstadoTableModel getTableModel() {
        if (tableModel == null) {
            try {
				tableModel = new EstadoTableModel(EstadoDao.ListaEstado());
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        }
        return tableModel;
    }
    private void Ajusta_Tamanho_Coluna(){
    	tblEstado.getTableHeader().setReorderingAllowed(false); 
    	tblEstado.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        tblEstado.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        tblEstado.getColumnModel().getColumn(0).setPreferredWidth(60);
        tblEstado.getColumnModel().getColumn(1).setPreferredWidth(60);
        tblEstado.getColumnModel().getColumn(2).setPreferredWidth(277);
    }
	
    private void initComponents() {
		setLayout(null);
		JLabel lblEstado = new JLabel("Cadastro de Estados");
		lblEstado.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblEstado.setBounds(10, 11, 224, 14);
		add(lblEstado);
		
		JButton btnFechar = new JButton("Fechar");
		btnFechar.setBorder(null);
		btnFechar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Agenda.mnCadastro.setEnabled(true);
				Agenda.mnRelatorio.setEnabled(true);
				Agenda.mnAjuda.setEnabled(true);
				Agenda.cardLayout.show (Agenda.painelBase, "principal");
			}
		});
		btnFechar.setOpaque(false);
		btnFechar.setMnemonic('F');
		btnFechar.setBounds(10, 228, 108, 23);
		add(btnFechar);

		Toolkit tk = Toolkit.getDefaultToolkit();
	    Dimension d = tk.getScreenSize();
	    //Screen width  = d.width
	    //Screen height = d.height
		
		JSeparator separator = new JSeparator();
		separator.setBounds(1, 26, d.width, 1);
		add(separator);
		
		JButton btnNewButton = new JButton("Pesquisar");
		btnNewButton.setBorder(null);
		btnNewButton.setMnemonic('P');
		btnNewButton.setOpaque(false);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnNewButton.setBounds(10, 58, 108, 23);
		add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("Visualisar");
		btnNewButton_1.setBorder(null);
		btnNewButton_1.setOpaque(false);
		btnNewButton_1.setMnemonic('V');
		btnNewButton_1.setBounds(10, 92, 108, 23);
		add(btnNewButton_1);
		
		JButton btnNewButton_2 = new JButton("Incluir");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
		        IncluiEstado TelaIncluiEstado = new IncluiEstado(null,"Incluir estado", true);
		        TelaIncluiEstado.setLocationRelativeTo(null);
		        TelaIncluiEstado.setVisible(true);
			}
		});
		btnNewButton_2.setBorder(null);
		btnNewButton_2.setOpaque(false);
		btnNewButton_2.setMnemonic('I');
		btnNewButton_2.setBounds(10, 126, 108, 23);
		add(btnNewButton_2);
		
		JButton btnNewButton_3 = new JButton("Alterar");
		btnNewButton_3.setBorder(null);
		btnNewButton_3.setMnemonic('A');
		btnNewButton_3.setOpaque(false);
		btnNewButton_3.setBounds(10, 160, 108, 23);
		add(btnNewButton_3);
		
		JButton btnNewButton_4 = new JButton("Excluir");
		btnNewButton_4.setBorder(null);
		btnNewButton_4.setOpaque(false);
		btnNewButton_4.setMnemonic('E');
		btnNewButton_4.setBounds(10, 194, 108, 23);
		add(btnNewButton_4);

    }
}

jdialog de inclusão (depois que eu fechar ele no botão fechar (ou no X) queria que atualiza-se a tabela

package view.Estado;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.*;
import javax.swing.border.EmptyBorder;

import model.EstadoBean;
import model.EstadoDao;
import util.Funcoes.Documento;
import view.jPnl_Estado;

import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Frame;

import javax.swing.JFormattedTextField;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.awt.event.ActionEvent;

@SuppressWarnings("serial")
public class IncluiEstado extends JDialog {

	private final JPanel contentPanel = new JPanel();
	public IncluiEstado(Frame owner, String title, boolean modal) {
		super(owner, title, modal);
		setTitle("Incluir Estado");
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setBounds(150, 60, 462, 191);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		JLabel lblUf = new JLabel("Uf");
		lblUf.setBounds(10, 52, 25, 14);
		lblUf.setFont(new Font("Tahoma", Font.PLAIN, 11));
		contentPanel.add(lblUf);
		
		JFormattedTextField jFTextUf = new JFormattedTextField();
		jFTextUf.setBounds(34, 49, 36, 20);
		jFTextUf.setDocument(new Documento("U",2,"[^aA-zZ]"));
		contentPanel.add(jFTextUf);

		JLabel lblNome = new JLabel("Nome");
		lblNome.setBounds(106, 52, 46, 14);
		contentPanel.add(lblNome);

		JFormattedTextField jFTextNome = new JFormattedTextField();
		jFTextNome.setBounds(153, 52, 230, 20);
		jFTextNome.setDocument(new Documento("S",20,"[^zA-zZ]"));
		contentPanel.add(jFTextNome);
		
		JPanel buttonPane = new JPanel();
		buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
		getContentPane().add(buttonPane, BorderLayout.SOUTH);

		JButton okButton = new JButton("Salvar");
		okButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if (!jFTextUf.getText().isEmpty()) {
					if (jFTextUf.getText().length() == 2) {
						if (jFTextNome.getText().isEmpty()) {
							JOptionPane.showMessageDialog(rootPane, "O campo nome não pode ficar vazio...");
						}else {
							EstadoBean estado = new EstadoBean();
							estado.setUf(jFTextUf.getText());
							estado.setNome(jFTextNome.getText());
							try {
								if (EstadoDao.TestaEstado(jFTextUf.getText())) {
									JOptionPane.showMessageDialog(rootPane, "Registro ja incluido anteriormente!");
								}else {
									try {
										EstadoDao.InserirEstado(estado);
										JOptionPane.showMessageDialog(rootPane, "Estado incluido com sucesso!");
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}
								}
							} catch (SQLException e){
								e.printStackTrace();
							}
							jFTextUf.setText("");
							jFTextNome.setText("");
						}
					}else {
						JOptionPane.showMessageDialog(rootPane, "O campo UF tem que ter 2 caracteres...");
					}
				}else {
					JOptionPane.showMessageDialog(rootPane, "O campo UF não pode ficar vazio...");
				}
			}
		});
		okButton.setActionCommand("OK");
		buttonPane.add(okButton);
		getRootPane().setDefaultButton(okButton);
		JButton cancelButton = new JButton("Fechar");
		cancelButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				dispose();
			}
		});
		cancelButton.setActionCommand("Cancel");
		buttonPane.add(cancelButton);
	}
}

Desde já agradeço novamente o apoio.

Christian

este é a classe da tablemodel, esqueci de postar, se precisar de mais alguma coisa, so avisar…

package controler;
import java.util.*;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

import model.EstadoBean;
public class EstadoTableModel extends AbstractTableModel{
	public static final int ID = 0;
	public static final int UF = 1;
	public static final int NOME = 2;
	private List<EstadoBean> listarEstados;
	private String[] colunas = new String[] { "Id", "Uf", "Nome" };
	
	public EstadoTableModel(){
		listarEstados = new ArrayList<EstadoBean>();
	}
	public EstadoTableModel(List<EstadoBean> lista){
		listarEstados = new ArrayList<EstadoBean>(lista);
	}
	public int getRowCount(){
		return listarEstados.size();
	}
	@Override
	public int getColumnCount() {
		return colunas.length;
	}
	@Override
	public String getColumnName(int columnIndex) {
		return colunas[columnIndex];
	}
	@Override
	public Class<?> getColumnClass(int columnIndex) {
	    switch (columnIndex) {
	    case ID:
	    	return int.class;
	    case UF:
	        return String.class;
	    case NOME:
	        return String.class;
	    default:
	        // Não deve ocorrer, pois só existem 3 colunas
	        throw new IndexOutOfBoundsException("columnIndex out of bounds");
	    }
	}
	@Override
	public boolean isCellEditable(int rowIndex, int columnIndex) {
	    return false;
	}
	public Object getValueAt(int rowIndex, int 	columnIndex){
		EstadoBean estado  = listarEstados.get(rowIndex);
		 switch (columnIndex) {
		    case ID:
		        return estado.getId();
		    case UF:
		        return estado.getUf();
		    case NOME:
		        return estado.getNome();
		    default:
		        // Não deve ocorrer, pois só existem 3 colunas
		        throw new IndexOutOfBoundsException("columnIndex out of bounds");
		 }
	}
	@Override
	public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
	    // Pega o estado referente a linha especificada.
		EstadoBean estado  = listarEstados.get(rowIndex);
	 
	    switch (columnIndex) {
	    case ID:
	        estado.setId((int) aValue);
	        break;
	    case UF:
	        estado.setUf((String) aValue);
	        break;
	    case NOME:
	        estado.setNome((String) aValue);
	        break;
	    default:
	        // Não deve ocorrer, pois só existem 3 colunas
	        throw new IndexOutOfBoundsException("columnIndex out of bounds");
	    }
	     
	    fireTableCellUpdated(rowIndex, columnIndex); // Notifica a atualização da célula
	}
	public EstadoBean getEstadoBean(int linhas){
		return listarEstados.get(linhas);
	}	
	public void add(EstadoBean estado) {
	    // Adiciona o registro.
	    listarEstados.add(estado);
	 
	    // Pega a quantidade de registros e subtrai 1 para
	    // achar o último índice. A subtração é necessária
	    // porque os índices começam em zero.
	    int ultimoIndice = getRowCount() - 1;
	 
	    // Notifica a mudança.
	    fireTableRowsInserted(ultimoIndice, ultimoIndice);
	}
	public void removeEstado(int indiceLinha) {
	    // Remove o registro.
	    listarEstados.remove(indiceLinha);
	 
	    // Notifica a mudança.
	    fireTableRowsDeleted(indiceLinha, indiceLinha);
	}
	public void addListaDeEstados(List<EstadoBean> estado) {
	    // Pega o tamanho antigo da tabela, que servirá
	    // como índice para o primeiro dos novos registros
	    int indice = getRowCount();
	 
	    // Adiciona os registros.
	    listarEstados.addAll(estado);
	 
	    // Notifica a mudança.
	    fireTableRowsInserted(indice, indice + estado.size());
	}
	public void limpar() {
	    // Remove todos os elementos da lista de sócios.
	    listarEstados.clear();
	 
	    // Notifica a mudança.
	    fireTableDataChanged();
	}
}

alguém pode ajudar ? nem que seja algum exemplo relacionado a estas classes,

Desde já agradeço

Crie um listener para sua janela de inclusão de estado:

package view.Estado;

import model.EstadoBean;

public interface IncluiEstadoListener {

    void incluiuEstado(EstadoBean estado);

}

Modifica a janela pra receber um listener como parâmetro:

package view.Estado;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.*;
import javax.swing.border.EmptyBorder;

import model.EstadoBean;
import model.EstadoDao;
import util.Funcoes.Documento;
import view.jPnl_Estado;

import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Frame;

import javax.swing.JFormattedTextField;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.awt.event.ActionEvent;

@SuppressWarnings("serial")
public class IncluiEstado extends JDialog {

    private IncluiEstadoListener listener;

    private final JPanel contentPanel = new JPanel();

    private JFormattedTextField jFTextUf;

    private JFormattedTextField jFTextNome;

    public IncluiEstado(Frame owner, String title, boolean modal, IncluiEstadoListener listener) {
        super(owner, title, modal);
        if (listener == null) {
            throw new IllegalArgumentException("Listener não pode ser null");
        }
        this.listener = listener;
        setTitle("Incluir Estado");
        setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        setBounds(150, 60, 462, 191);
        getContentPane().setLayout(new BorderLayout());
        contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
        getContentPane().add(contentPanel, BorderLayout.CENTER);
        contentPanel.setLayout(null);

        JLabel lblUf = new JLabel("Uf");
        lblUf.setBounds(10, 52, 25, 14);
        lblUf.setFont(new Font("Tahoma", Font.PLAIN, 11));
        contentPanel.add(lblUf);

        jFTextUf = new JFormattedTextField();
        jFTextUf.setBounds(34, 49, 36, 20);
        jFTextUf.setDocument(new Documento("U", 2, "[^aA-zZ]"));
        contentPanel.add(jFTextUf);

        JLabel lblNome = new JLabel("Nome");
        lblNome.setBounds(106, 52, 46, 14);
        contentPanel.add(lblNome);

        jFTextNome = new JFormattedTextField();
        jFTextNome.setBounds(153, 52, 230, 20);
        jFTextNome.setDocument(new Documento("S", 20, "[^zA-zZ]"));
        contentPanel.add(jFTextNome);

        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);

        JButton okButton = new JButton("Salvar");
        okButton.addActionListener(event -> clicouNoBotaoOK());
        okButton.setActionCommand("OK");
        buttonPane.add(okButton);
        getRootPane().setDefaultButton(okButton);
        JButton cancelButton = new JButton("Fechar");
        cancelButton.addActionListener(event -> clicouNoBotaoCancel());
        cancelButton.setActionCommand("Cancel");
        buttonPane.add(cancelButton);
    }

    private void clicouNoBotaoOK() {
        String ufInformada = jFTextUf.getText();
        if (ufInformada.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, "O campo UF não pode ficar vazio...");
            return;
        }
        if (ufInformada.length() != 2) {
            JOptionPane.showMessageDialog(rootPane, "O campo UF tem que ter 2 caracteres...");
            return;
        }
        String nomeInformado = jFTextNome.getText();
        if (nomeInformado.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, "O campo nome não pode ficar vazio...");
            return;
        }
        if (EstadoDao.TestaEstado(ufInformada)) {
            JOptionPane.showMessageDialog(rootPane, "Registro ja incluido anteriormente!");
            return;
        }
        try {
            EstadoBean estado = new EstadoBean();
            estado.setUf(ufInformada);
            estado.setNome(nomeInformado);
            EstadoDao.InserirEstado(estado);
            JOptionPane.showMessageDialog(rootPane, "Estado incluido com sucesso!");
            listener.incluiuEstado(estado);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        jFTextUf.setText("");
        jFTextNome.setText("");
    }

    private void clicouNoBotaoCancel() {
        dispose();
    }
}

Aí no painél do estado você registra um listener ao criar a janela de diálogo:

package view;

import javax.swing.JLabel;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import java.awt.Font;

import model.EstadoBean;
import model.EstadoDao;
import view.Estado.IncluiEstado;
import view.Estado.IncluiEstadoListener;

import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.awt.event.ActionEvent;
import javax.swing.JTable;

import controler.EstadoTableModel;
import javax.swing.ListSelectionModel;

@SuppressWarnings("serial")
public class jPnl_Estado extends JPanel {

    private JTable tblEstado;
    private EstadoTableModel tableModel;
    private JScrollPane rolagem;

    public jPnl_Estado() {
        initComponents();
        rolagem = new JScrollPane(getTblEstado());
        add(rolagem);
        rolagem.setBounds(150, 60, 400, 400);
    }

    private JTable getTblEstado() {
        if (tblEstado == null) {
            tblEstado = new JTable();
            tblEstado.setModel(getTableModel());
            Ajusta_Tamanho_Coluna();
        }
        return tblEstado;
    }

    private EstadoTableModel getTableModel() {
        if (tableModel == null) {
            try {
                tableModel = new EstadoTableModel(EstadoDao.ListaEstado());
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return tableModel;
    }

    private void Ajusta_Tamanho_Coluna() {
        tblEstado.getTableHeader().setReorderingAllowed(false);
        tblEstado.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        tblEstado.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        tblEstado.getColumnModel().getColumn(0).setPreferredWidth(60);
        tblEstado.getColumnModel().getColumn(1).setPreferredWidth(60);
        tblEstado.getColumnModel().getColumn(2).setPreferredWidth(277);
    }

    private void initComponents() {
        setLayout(null);
        JLabel lblEstado = new JLabel("Cadastro de Estados");
        lblEstado.setFont(new Font("Tahoma", Font.BOLD, 12));
        lblEstado.setBounds(10, 11, 224, 14);
        add(lblEstado);

        JButton btnFechar = new JButton("Fechar");
        btnFechar.setBorder(null);
        btnFechar.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Agenda.mnCadastro.setEnabled(true);
                Agenda.mnRelatorio.setEnabled(true);
                Agenda.mnAjuda.setEnabled(true);
                Agenda.cardLayout.show(Agenda.painelBase, "principal");
            }
        });
        btnFechar.setOpaque(false);
        btnFechar.setMnemonic('F');
        btnFechar.setBounds(10, 228, 108, 23);
        add(btnFechar);

        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        // Screen width = d.width
        // Screen height = d.height

        JSeparator separator = new JSeparator();
        separator.setBounds(1, 26, d.width, 1);
        add(separator);

        JButton btnNewButton = new JButton("Pesquisar");
        btnNewButton.setBorder(null);
        btnNewButton.setMnemonic('P');
        btnNewButton.setOpaque(false);
        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {}
        });
        btnNewButton.setBounds(10, 58, 108, 23);
        add(btnNewButton);

        JButton btnNewButton_1 = new JButton("Visualisar");
        btnNewButton_1.setBorder(null);
        btnNewButton_1.setOpaque(false);
        btnNewButton_1.setMnemonic('V');
        btnNewButton_1.setBounds(10, 92, 108, 23);
        add(btnNewButton_1);

        JButton btnNewButton_2 = new JButton("Incluir");
        btnNewButton_2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                IncluiEstado TelaIncluiEstado = new IncluiEstado(null, "Incluir estado", true, new IncluiEstadoListener() {

                    @Override
                    public void incluiuEstado(EstadoBean estado) {
                        // aqui você atualiza sua tabela
                    }
                });
                TelaIncluiEstado.setLocationRelativeTo(null);
                TelaIncluiEstado.setVisible(true);
            }
        });
        btnNewButton_2.setBorder(null);
        btnNewButton_2.setOpaque(false);
        btnNewButton_2.setMnemonic('I');
        btnNewButton_2.setBounds(10, 126, 108, 23);
        add(btnNewButton_2);

        JButton btnNewButton_3 = new JButton("Alterar");
        btnNewButton_3.setBorder(null);
        btnNewButton_3.setMnemonic('A');
        btnNewButton_3.setOpaque(false);
        btnNewButton_3.setBounds(10, 160, 108, 23);
        add(btnNewButton_3);

        JButton btnNewButton_4 = new JButton("Excluir");
        btnNewButton_4.setBorder(null);
        btnNewButton_4.setOpaque(false);
        btnNewButton_4.setMnemonic('E');
        btnNewButton_4.setBounds(10, 194, 108, 23);
        add(btnNewButton_4);
        }
}