When I try to get my JDialog containing the correct info (fed in through my custom object WeatherCard) to display, it disappears an instant after creation. Did I miss something or did I just fudge it too hard?
public void printWeatherCard(WeatherCard w, JFrame controlFrame) throws MalformedURLException, IOException{
/* Displays a dialog box containing the temperature and location */
// BufferedImage img = ImageIO.read(new URL(w.imgSrc));
// ImageIcon icon = new ImageIcon(img);
// JOptionPane.showMessageDialog(controlFrame, "It is currently " + w.currentTemp + " \u00B0 F in " + w.location.city + ", " + w.location.state + ".\nCurrent humidity: " + w.currentHumidity/* +
//"%.\nChance of precipitation: " + w.chancePrecip + "%."*/, "Weather Update: " + w.location.zipCode, JOptionPane.INFORMATION_MESSAGE, icon);
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(0, 1));
Label lb = new Label("It is currently " + w.currentTemp + " \u00B0 F in " + w.location.city + ", " + w.location.state + ".\nCurrent humidity: " + w.currentHumidity);
panel.add(lb);
final JDialog dialog = new JDialog(controlFrame, "Weather Update: " + w.location.zipCode);
dialog.setSize(500,500);
dialog.add(panel);
dialog.pack();
Timer timer = new Timer(10000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.setVisible(false);
dialog.dispose();
}
});
timer.setRepeats(false);
timer.start();
dialog.setVisible(true);
}