Skip to main content

Saving a table to a .csv, constructor not visible from event listener

1 reply [Last post]

I'm writing a code for a table to input and store data about students. I am having a problem with the last bit of code.

here is what the code looks like

public class StudentTable extends JPanel implements{

private boolean DEBUG = false;

public StudentTable() {

class SaveListener implements ActionListener{
public void actionPerformed(ActionEvent event) {
grid.saveAsCSV(new StudentTable("StudentTable.csv"), true );

} the error im getting is the constructor StudentTable cannot be found
can someone please help?
i cant figure it out for the life of me!


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-05-05

That's because you created a constructor with no arguments, yet you're trying to put an argument in it. If you need StudentTable() with no arguments, you can have an overloaded constructor:
class StudentTable {
public StudentTable() {
// do stuff

public StudentTable(String aString) {
// do other stuff