I am having a problem initializing a JTable from a FOR with BD or an array.
My problem is the example tableFilterDemo.java, I need the funcionality of this,
but when I want load data of my BD or an arraylist I have the problem.
I need load the array of objects with a FOR getting all the lines of file or rows of table
private Object[][] data = {
{ "Mary", "Campione", "Snowboarding"},
{ "John", "guifru", "skyiin"},};
You can always use the DefaultTableModel which uses a Vector of Vectors to hold the data in the TableModel. So for each row in the table you create a Vector and add each column to the Vecter. Then you add the row Vector to a second Vector. This way you don’t need to hardcode the size of the Arrays in advance. Table From Database shows how you can use this approach.
Or you can always use a custom TableModel if you want to display custom Ojects that are stored in an ArrayList. The Row Table Model provides some general support for storing objects in an ArrayList. You would also want to look at the
BeanTableModelfor a full implementation and a further example of how to do a custom implementation.