Place a table created in an existing container

1

I need help!

I'm developing an application in college that will use BubbleSort - yes! We had the misfortune to get this! - to sort some data within a table.

I created the table through a class that extended AbstractTableModel, however I can not get it to stay in the jPanel I created with Swing. Does anyone know how to solve it?

link

In this link is the project made in netbeans - the code is a bit messy. I hope you understand.

In the 'table' package are the table definition classes. In the 'screen' package is the RecordScreen class - which is the class in which I am trying to put the table. Based on it.

I appreciate the attention of those who can help.

    
asked by anonymous 26.08.2016 / 18:22

1 answer

3

In the constructor TelaRegistrar() , just below initComponents() , change as below:

public TelaRegistrar() {
        this.funcoes = new ArrayList<>();
//        this.tela = new ListaFuncoesView(funcoes);
//        tela.setVisible(true);

        initComponents();

        FuncaoModeloTabela mod = new FuncaoModeloTabela(funcoes);
        tblReg.setModel(mod);

}

Since you have created your own TableModel with the Tabela class, simply pass the FuncaoModeloTabela class (which seems to complement the Tabela class when you extend it) using the suaTable.setModel(TableModel dataModel) method.

The ListaFuncoesView class becomes unnecessary with this change, since its function was to only display the table on a separate screen.

Another important tip is to always add a JTable to a JScrollPane , so the header of your table will be displayed correctly and, if you have many rows, the container will adjust the vertical scroll automatically.

    
26.08.2016 / 19:16