I have a main class that uses a swing interface. There is a JScrollPane that i can get to show up. I have an actionlistener that fills the table and is supposed to add the table to the JScrollPane. however when i initialize the scrollPane i need to declare (table example) as an argument...cant figure out how to reference it after its been populated. heres the code:
JScrollPane callsScroll = new JScrollPane();
JPanel callsArea = new JPanel();
....
callsArea.add(callsScroll);
callsScroll.setPreferredSize(new Dimension(570, 400));
...
while (rs.next()) {
String columns[] = {"Employee ID", "Date", "Billing Type", "DR", "Call Time", "Trouble Code", "Invoice Amount", "Invoice Number"};
Object data[][]={
{rs.getString("EmployeeID"),rs.getString("Date"),rs.getString("BillingType"),
rs.getString("DR"),rs.getString("CallTime"),rs.getString("TroubleCode"),
rs.getString("InvoiceAmount"),rs.getString("InvoiceNumber")
},
};
JTable table = new JTable(data,columns);
gui.callsScroll.add(table);
gui.callsArea.add(gui.callsScroll);
}
i know the table is being populated because i can add it straight to the JFrame. but i cannot get it into the table first. i need to be able to reference the instance of the table after its been populated here JScrollPane callsScroll = new JScrollPane(right here);
******EDIT**************
Object[][] data=null;
while (rs.next()) {
data[][]={
{rs.getString("EmployeeID"),rs.getString("Date"),rs.getString("BillingType"),
rs.getString("DR"),rs.getString("CallTime"),rs.getString("TroubleCode"),
rs.getString("InvoiceAmount"),rs.getString("InvoiceNumber")},
};
}