Java jtable, parameter error?

Asked

Viewed 35 times

0

I’m having a hard time getting through parameters for my jTable, these parameters being a Object[][] and a String[].

tabela = new JTable(dados, colunas);

It does not work the data is a matrix like this:

dados = new Object[1][contador_de_grupos];

And the columns like this:

colunas[i] = "Grupo "+ i+1; 

Where the data of the columns receive the names of the groups within a loop of repetition, because the v=header is not static will increase or decrease in size depending on the number of groups created at the time of calculation

  • 1

    What a mistake you’re making?

  • Look, if the intention is to have columns of dynamical size, your approach is quite wrong. Vectors ALWAYS need to have their size defined, be one-dimensional(e.g..: int[] vet) or multidimensional(e.g..: int[][] matriz). You cannot pass a value as dimension that is not set. If you want to use dynamic columns, you need to create your own Tablemodel.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.