1
I made a Jdialog that will show some statistics of the users who use the software, but I’m not able to make the columns name appear. I tried to add using the .addColumn model but not working.
class Estatisticas extends JDialog{
public Estatisticas(){
setIconImage(Toolkit.getDefaultToolkit().getImage(Sobre.class.getResource("/img/info.png")));
setModal(true);
setTitle("Estatísticas");
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 340, 300);
JPanel contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
File[] diretorio = new File("./usuarios/").listFiles();
DefaultTableModel modelo = new DefaultTableModel();
modelo.addColumn("Usuário");
modelo.addColumn("Acessos");
String[] row = new String[2];
for (File file : diretorio) {
if (file.isFile()) {
try {
row[0] = file.getName().substring(0, file.getName().length() - 11);
row[1] = retornaAcessoArquivo(file.getName());
modelo.addRow(row);
} catch (IOException e) {
e.printStackTrace();
}
}
}
JTable tblEstatisticas = new JTable(modelo);
contentPane.add(tblEstatisticas);
}
}