I am setting up a table in java and it starts with a blank row. When I go to add my data the first row is always blank. How do I correct that. I'm not sure what code to attach so if someone sees some code I have not attached I will do so. Thanks.
String homePlayerData[][] = {{"", "", "", "", ""}};
String homePlayerCol[] = {"Number", "Player", "Points", "Fouls"};
DefaultTableModel homeTable = new DefaultTableModel(homePlayerData, homePlayerCol);
while (rec.next()) {
if (team.equals("home")) {
homeTable.addRow(new Object[]{
rec.getString("number"),
rec.getString("name"),
rec.getString("points"),
rec.getString("fouls"),
});
} else {
visitorTable.addRow(new Object[]{
rec.getString("number"),
rec.getString("name"),
rec.getString("points"),
rec.getString("fouls"),
});
}
}
I would generally use the Vector type of TableModel rather than Object[]. The latter is for fixed conditions. Also your else-if is odd: you do precisely the same thing in each case
http://technojeeves.com/joomla/index.php/free/59-resultset-to-tablemodel