I am to create an GUI that takes data I've read into an ArrayList, and perform actions on that data such as displaying, sorting and calculations.
My information is weather data.
In a class called "FileReading", I read my data from a csv into an ArrayList. I need to then pass this information to my JFrame GUI class named "WeatherGUI" and perform said actions on the data.
I am having trouble passing the information from my ArrayList over to my GUI class. As I've tested that it's reading data into the ArrayList fine, I won't include that code.
This is the relevant code I have in my WeatherGUI class and I'll describe the error below
public class WeatherGUI extends JFrame implements ActionListener {
private ArrayList<Weather> weather;
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
WeatherGUI frame = new WeatherGUI();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public WeatherGUI(ArrayList<Weather> weather) {
super("Weather");
this.weather = weather;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 692, 561);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
}
The error I'm having is in the try statement where WeatherGUI wants a parameter relating to my ArrayList and I'm not sure what to put here. If I put in "weather" it tells me to make weather static which I know isn't correct. The code I've added is what the lecturer provided in a slide but I still get the error.