Open main menu

CDOT Wiki β

WeatherDialog.java

Revision as of 16:33, 16 April 2011 by Thupten (talk | contribs) (Created page with '<syntaxhighlight lang="java"> package ecl.team2.project.weathersystem.client; import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; im…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
package ecl.team2.project.weathersystem.client;

import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import ecl.team2.project.weather.Weather;
import ecl.team2.project.weather.WeatherAndCurrent;
import ecl.team2.project.weather.WeatherInterface;

public class WeatherDialog extends javax.swing.JFrame implements WindowListener, ActionListener, ItemListener{
	private static final long serialVersionUID = 1L;
	WeatherInterface sws;
	String chosencity="";
	String unitTemp = "C";
	String unitSpeed = "km"; 
	ArrayList<JLabel> lblDates = null;
	ArrayList<JLabel> lblDays = null;
	ArrayList<JLabel> lblTempMaxes = null;
	ArrayList<JLabel> lblTempMins = null;
	ArrayList<JLabel> lblImages = null;
	ArrayList<JLabel> lblRains = null;
	ArrayList<JLabel> lblClouds = null;
	ArrayList<JLabel> lblWinds = null;
	ArrayList<JLabel> lblWindDirections = null;

	/** Creates new form WeatherDialog */
	public WeatherDialog() {
		initComponents();
		this.setTitle("Weather Anywhere v1.0.0");
		this.addWindowListener(this);
		jMenuItem1.addActionListener(this); //about
		jMenuItem2.addActionListener(this); //help
		jMenuItem3.addActionListener(this); //setup location
		jMenuItem4.addActionListener(this); //options
		jMenuItem5.addActionListener(this); //exit
		btnChange.addActionListener(this); //change unit
		
		// Display the window.
		this.pack();
		this.setSize(500, 690);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
		this.setLocationRelativeTo(null);
	}
	
	

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	private void initComponents() {

		panelCurrentCondition = new javax.swing.JPanel();
		lblCondition = new javax.swing.JLabel();
		lblWind = new javax.swing.JLabel();
		lblTemp = new javax.swing.JLabel();
		lblHumidity = new javax.swing.JLabel();
		lblPressure = new javax.swing.JLabel();
		lblCloud = new javax.swing.JLabel();
		lblVisibility = new javax.swing.JLabel();
		lblCurrentImage = new JLabel();

		jLabel1 = new javax.swing.JLabel();

		panel0 = new javax.swing.JPanel();
		lblDate0 = new javax.swing.JLabel();
		lblDay0 = new javax.swing.JLabel();
		lblMaxtemp0 = new javax.swing.JLabel();
		lblMintemp0 = new javax.swing.JLabel();
		lblImage0 = new javax.swing.JLabel();
		lblRain0 = new javax.swing.JLabel();
		lblCloud0 = new javax.swing.JLabel();
		lblWind0 = new javax.swing.JLabel();
		lblWindDirection0 = new javax.swing.JLabel();

		jLabel2 = new javax.swing.JLabel();

		panel1 = new javax.swing.JPanel();
		lblDate1 = new javax.swing.JLabel();
		lblDay1 = new javax.swing.JLabel();
		lblMaxtemp1 = new javax.swing.JLabel();
		lblMintemp1 = new javax.swing.JLabel();
		lblImage1 = new javax.swing.JLabel();
		lblRain1 = new javax.swing.JLabel();
		lblCloud1 = new javax.swing.JLabel();
		lblWind1 = new javax.swing.JLabel();
		lblWindDirection1 = new javax.swing.JLabel();

		panel2 = new javax.swing.JPanel();
		lblDate2 = new javax.swing.JLabel();
		lblDay2 = new javax.swing.JLabel();
		lblMaxtemp2 = new javax.swing.JLabel();
		lblMintemp2 = new javax.swing.JLabel();
		lblImage2 = new javax.swing.JLabel();
		lblRain2 = new javax.swing.JLabel();
		lblCloud2 = new javax.swing.JLabel();
		lblWind2 = new javax.swing.JLabel();
		lblWindDirection2 = new javax.swing.JLabel();

		panel3 = new javax.swing.JPanel();
		lblDate3 = new javax.swing.JLabel();
		lblDay3 = new javax.swing.JLabel();
		lblMaxtemp3 = new javax.swing.JLabel();
		lblMintemp3 = new javax.swing.JLabel();
		lblImage3 = new javax.swing.JLabel();
		lblRain3 = new javax.swing.JLabel();
		lblCloud3 = new javax.swing.JLabel();
		lblWind3 = new javax.swing.JLabel();
		lblWindDirection3 = new javax.swing.JLabel();

		
		panel5 = new javax.swing.JPanel();
		btnChange = new javax.swing.JButton();
		
		jMenuBar1 = new javax.swing.JMenuBar();
		jMenu1 = new javax.swing.JMenu();
		jMenuItem3 = new javax.swing.JMenuItem();
		jMenuItem4 = new javax.swing.JMenuItem();
		jMenuItem5 = new javax.swing.JMenuItem();
		jMenu2 = new javax.swing.JMenu();
		jMenuItem2 = new javax.swing.JMenuItem();
		jMenuItem1 = new javax.swing.JMenuItem();
		
		

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

		panelCurrentCondition.setBorder(javax.swing.BorderFactory.createEtchedBorder());

		javax.swing.GroupLayout panelCurrentConditionLayout = new javax.swing.GroupLayout(panelCurrentCondition);
		panelCurrentCondition.setLayout(panelCurrentConditionLayout);
		panelCurrentConditionLayout.setHorizontalGroup(
				panelCurrentConditionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(panelCurrentConditionLayout.createSequentialGroup()
						.addContainerGap()
						.addGroup(panelCurrentConditionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
								.addComponent(lblTemp)
								.addComponent(lblCondition)
								.addComponent(lblWind))
								.addGap(33, 33, 33)
								.addGroup(panelCurrentConditionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
										.addComponent(lblPressure)
										.addComponent(lblHumidity)
										.addComponent(lblCloud)
										.addComponent(lblVisibility))
										.addGap(79, 79, 79)
										.addComponent(lblCurrentImage, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(22, 22, 22))
		);
		panelCurrentConditionLayout.setVerticalGroup(
				panelCurrentConditionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(panelCurrentConditionLayout.createSequentialGroup()
						.addContainerGap()
						.addGroup(panelCurrentConditionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
								.addGroup(panelCurrentConditionLayout.createSequentialGroup()
										.addGap(20, 20, 20)
										.addComponent(lblCondition)
										.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(lblWind))
										.addComponent(lblTemp)
										.addGroup(panelCurrentConditionLayout.createSequentialGroup()
												.addComponent(lblHumidity)
												.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
												.addComponent(lblPressure)
												.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
												.addComponent(lblCloud)
												.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
												.addComponent(lblVisibility))
												.addComponent(lblCurrentImage, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 74, Short.MAX_VALUE))
												.addContainerGap())
		);

		jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
		jLabel1.setText("Current Condition");


		panel0.setBorder(javax.swing.BorderFactory.createEtchedBorder());

		javax.swing.GroupLayout panel0Layout = new javax.swing.GroupLayout(panel0);
		panel0.setLayout(panel0Layout);
		panel0Layout.setHorizontalGroup(
				panel0Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(panel0Layout.createSequentialGroup()
						.addContainerGap()
						.addGroup(panel0Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
								.addComponent(lblDate0)
								.addComponent(lblDay0))
								.addGap(18, 18, 18)
								.addComponent(lblImage0, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
								.addGap(26, 26, 26)
								.addGroup(panel0Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
										.addGroup(panel0Layout.createSequentialGroup()
												.addComponent(lblMaxtemp0)
												.addGap(18, 18, 18)
												.addComponent(lblRain0)
												.addGap(31, 31, 31)
												.addComponent(lblWind0))
												.addGroup(panel0Layout.createSequentialGroup()
														.addComponent(lblMintemp0)
														.addGap(31, 31, 31)
														.addComponent(lblCloud0)
														.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
														.addComponent(lblWindDirection0)))
														.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		panel0Layout.setVerticalGroup(
				panel0Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(panel0Layout.createSequentialGroup()
						.addGroup(panel0Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
								.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel0Layout.createSequentialGroup()
										.addContainerGap()
										.addComponent(lblImage0, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE))
										.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel0Layout.createSequentialGroup()
												.addGap(16, 16, 16)
												.addComponent(lblDay0)
												.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
												.addComponent(lblDate0))
												.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel0Layout.createSequentialGroup()
														.addGap(20, 20, 20)
														.addGroup(panel0Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
																.addComponent(lblRain0)
																.addComponent(lblWind0)
																.addComponent(lblMaxtemp0))
																.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(panel0Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
																		.addComponent(lblCloud0)
																		.addComponent(lblMintemp0)
																		.addComponent(lblWindDirection0))))
																		.addContainerGap())
		);

		jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
		jLabel2.setText("Forecast");

		panel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

		javax.swing.GroupLayout panel1Layout = new javax.swing.GroupLayout(panel1);
		panel1.setLayout(panel1Layout);
		panel1Layout.setHorizontalGroup(
				panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(panel1Layout.createSequentialGroup()
						.addContainerGap()
						.addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
								.addComponent(lblDate1)
								.addComponent(lblDay1))
								.addGap(18, 18, 18)
								.addComponent(lblImage1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
								.addGap(26, 26, 26)
								.addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
										.addGroup(panel1Layout.createSequentialGroup()
												.addComponent(lblMaxtemp1)
												.addGap(18, 18, 18)
												.addComponent(lblRain1)
												.addGap(31, 31, 31)
												.addComponent(lblWind1))
												.addGroup(panel1Layout.createSequentialGroup()
														.addComponent(lblMintemp1)
														.addGap(31, 31, 31)
														.addComponent(lblCloud1)
														.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
														.addComponent(lblWindDirection1)))
														.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		panel1Layout.setVerticalGroup(
				panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(panel1Layout.createSequentialGroup()
						.addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
								.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel1Layout.createSequentialGroup()
										.addContainerGap()
										.addComponent(lblImage1, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE))
										.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel1Layout.createSequentialGroup()
												.addGap(16, 16, 16)
												.addComponent(lblDay1)
												.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
												.addComponent(lblDate1))
												.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel1Layout.createSequentialGroup()
														.addGap(20, 20, 20)
														.addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
																.addComponent(lblRain1)
																.addComponent(lblWind1)
																.addComponent(lblMaxtemp1))
																.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
																		.addComponent(lblCloud1)
																		.addComponent(lblMintemp1)
																		.addComponent(lblWindDirection1))))
																		.addContainerGap())
		);

		panel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

		javax.swing.GroupLayout panel2Layout = new javax.swing.GroupLayout(panel2);
		panel2.setLayout(panel2Layout);
		panel2Layout.setHorizontalGroup(
				panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(panel2Layout.createSequentialGroup()
						.addContainerGap()
						.addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
								.addComponent(lblDate2)
								.addComponent(lblDay2))
								.addGap(18, 18, 18)
								.addComponent(lblImage2, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
								.addGap(26, 26, 26)
								.addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
										.addGroup(panel2Layout.createSequentialGroup()
												.addComponent(lblMaxtemp2)
												.addGap(18, 18, 18)
												.addComponent(lblRain2)
												.addGap(31, 31, 31)
												.addComponent(lblWind2))
												.addGroup(panel2Layout.createSequentialGroup()
														.addComponent(lblMintemp2)
														.addGap(31, 31, 31)
														.addComponent(lblCloud2)
														.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
														.addComponent(lblWindDirection2)))
														.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		panel2Layout.setVerticalGroup(
				panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(panel2Layout.createSequentialGroup()
						.addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
								.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel2Layout.createSequentialGroup()
										.addContainerGap()
										.addComponent(lblImage2, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE))
										.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel2Layout.createSequentialGroup()
												.addGap(16, 16, 16)
												.addComponent(lblDay2)
												.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
												.addComponent(lblDate2))
												.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel2Layout.createSequentialGroup()
														.addGap(20, 20, 20)
														.addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
																.addComponent(lblRain2)
																.addComponent(lblWind2)
																.addComponent(lblMaxtemp2))
																.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(panel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
																		.addComponent(lblCloud2)
																		.addComponent(lblMintemp2)
																		.addComponent(lblWindDirection2))))
																		.addContainerGap())
		);

		panel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());


		javax.swing.GroupLayout panel3Layout = new javax.swing.GroupLayout(panel3);
		panel3.setLayout(panel3Layout);
		panel3Layout.setHorizontalGroup(
				panel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(panel3Layout.createSequentialGroup()
						.addContainerGap()
						.addGroup(panel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
								.addComponent(lblDate3)
								.addComponent(lblDay3))
								.addGap(18, 18, 18)
								.addComponent(lblImage3, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
								.addGap(26, 26, 26)
								.addGroup(panel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
										.addGroup(panel3Layout.createSequentialGroup()
												.addComponent(lblMaxtemp3)
												.addGap(18, 18, 18)
												.addComponent(lblRain3)
												.addGap(31, 31, 31)
												.addComponent(lblWind3))
												.addGroup(panel3Layout.createSequentialGroup()
														.addComponent(lblMintemp3)
														.addGap(31, 31, 31)
														.addComponent(lblCloud3)
														.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
														.addComponent(lblWindDirection3)))
														.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		panel3Layout.setVerticalGroup(
				panel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(panel3Layout.createSequentialGroup()
						.addGroup(panel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
								.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel3Layout.createSequentialGroup()
										.addContainerGap()
										.addComponent(lblImage3, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE))
										.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel3Layout.createSequentialGroup()
												.addGap(16, 16, 16)
												.addComponent(lblDay3)
												.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
												.addComponent(lblDate3))
												.addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel3Layout.createSequentialGroup()
														.addGap(20, 20, 20)
														.addGroup(panel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
																.addComponent(lblRain3)
																.addComponent(lblWind3)
																.addComponent(lblMaxtemp3))
																.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addGroup(panel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
																		.addComponent(lblCloud3)
																		.addComponent(lblMintemp3)
																		.addComponent(lblWindDirection3))))
																		.addContainerGap())
		);
		
		
		 panel5.setBorder(javax.swing.BorderFactory.createEmptyBorder());

		 this.btnChange.setText("Change to US System");

	        javax.swing.GroupLayout panel5Layout = new javax.swing.GroupLayout(panel5);
	        panel5.setLayout(panel5Layout);
	        panel5Layout.setHorizontalGroup(
	            panel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	            .addGroup(panel5Layout.createSequentialGroup()
	                .addGap(96, 96, 96)
	                .addComponent(this.btnChange, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
	                .addContainerGap(111, Short.MAX_VALUE))
	        );
	        panel5Layout.setVerticalGroup(
	            panel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel5Layout.createSequentialGroup()
	                .addContainerGap(21, Short.MAX_VALUE)
	                .addComponent(this.btnChange)
	                .addContainerGap())
	        );
		
		
		/*arraylists to hold all the labels*/
		lblDates = new ArrayList<JLabel>();
		lblDates.add(this.lblDate0);lblDates.add(this.lblDate1);lblDates.add(this.lblDate2);lblDates.add(this.lblDate3);

		lblDays = new ArrayList<JLabel>();
		lblDays.add(this.lblDay0);lblDays.add(this.lblDay1);lblDays.add(this.lblDay2);lblDays.add(this.lblDay3);

		lblTempMaxes = new ArrayList<JLabel>();
		lblTempMaxes.add(this.lblMaxtemp0);lblTempMaxes.add(this.lblMaxtemp1);lblTempMaxes.add(this.lblMaxtemp2);lblTempMaxes.add(this.lblMaxtemp3);

		lblTempMins = new ArrayList<JLabel>();
		lblTempMins.add(this.lblMintemp0);lblTempMins.add(this.lblMintemp1);lblTempMins.add(this.lblMintemp2);lblTempMins.add(this.lblMintemp3);

		lblImages = new ArrayList<JLabel>();
		lblImages.add(this.lblImage0);lblImages.add(this.lblImage1);lblImages.add(this.lblImage2);lblImages.add(this.lblImage3);

		lblRains = new ArrayList<JLabel>();
		lblRains.add(this.lblRain0);lblRains.add(this.lblRain1);lblRains.add(this.lblRain2);lblRains.add(this.lblRain3);

		lblClouds = new ArrayList<JLabel>();
		lblClouds.add(this.lblCloud0);lblClouds.add(this.lblCloud1);lblClouds.add(this.lblCloud2);lblClouds.add(this.lblCloud3);

		lblWinds = new ArrayList<JLabel>();
		lblWinds.add(this.lblWind0);lblWinds.add(this.lblWind1);lblWinds.add(this.lblWind2);lblWinds.add(this.lblWind3);

		lblWindDirections = new ArrayList<JLabel>();
		lblWindDirections.add(this.lblWindDirection0);lblWindDirections.add(this.lblWindDirection1);lblWindDirections.add(this.lblWindDirection2);lblWindDirections.add(this.lblWindDirection3);


		jMenu1.setText("File");

		jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem3.setText("Setup Location...");
		jMenu1.add(jMenuItem3);

		jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem4.setText("Options...");
		jMenu1.add(jMenuItem4);

		jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem5.setText("Exit");
		jMenu1.add(jMenuItem5);

		jMenuBar1.add(jMenu1);

		jMenu2.setText("Help");

		jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
		jMenuItem2.setText("Help");
		jMenu2.add(jMenuItem2);

		jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F10, 0));
		jMenuItem1.setText("About");
		jMenu2.add(jMenuItem1);

		jMenuBar1.add(jMenu2);

		setJMenuBar(jMenuBar1);
		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelCurrentCondition, javax.swing.GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
                    .addComponent(panel0, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1)
                    .addComponent(panel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelCurrentCondition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addGap(4, 4, 4)
                .addComponent(panel0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(panel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(panel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(panel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                .addComponent(panel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );


		pack();
	}// </editor-fold>


	public void ShowWeather(String city){
		
		try {		
			//get a current condition here
	//		CurrentCondition c = c.getCurrent();
			WeatherAndCurrent c= sws.getWeather(city);
			this.jLabel1.setText("Current Condition in "+ city.toUpperCase());
			if(unitTemp.toLowerCase().equals("c")){
				this.lblTemp.setText(c.getCurrent().getTemp_C()+" ºC");
			}else{
				this.lblTemp.setText(c.getCurrent().getTemp_F()+" ºF");
			}
			
			this.lblCondition.setText(c.getCurrent().getWeatherDesc());
			if(unitSpeed.toLowerCase().equals("km")){
				this.lblWind.setText(c.getCurrent().getWindspeedKmph()+" kmph from " + c.getCurrent().getWinddir16Point());
				}
			else{
				this.lblWind.setText(c.getCurrent().getWindspeedMiles()+" mph from " + c.getCurrent().getWinddir16Point());
				}
			this.lblHumidity.setText("Humidity: "+c.getCurrent().getHumidity()+" %");
			this.lblPressure.setText("Pressure: "+c.getCurrent().getPressure()+" mb");
			this.lblCloud.setText("Cloud: "+c.getCurrent().getCloudcover()+" %");
			this.lblVisibility.setText("Visibility: "+c.getCurrent().getVisibility()+" km");

			Image image = null;
			   try {
			       //Read from a URL
			       URL url = new URL(c.getCurrent().getWeatherIconUrl());
			       image = ImageIO.read(url);
			   } catch (IOException e) {
			   }
			   this.lblCurrentImage.setIcon(new ImageIcon(image));
			
			//get the weathers here
			int index = 0;
			for(index = 0;index<4; index++){
				Weather w = c.getWeathers().get(index);
				if(unitTemp.toUpperCase().equals("C")){
					this.lblTempMaxes.get(index).setText("Max: "+w.getTempMaxC() + " ºC");
					this.lblTempMins.get(index).setText("Min: "+w.getTempMinC() + " ºC");
				}else{
					this.lblTempMaxes.get(index).setText("Max: "+w.getTempMaxF() + " ºF");
					this.lblTempMins.get(index).setText("Min: "+w.getTempMinF() + " ºF");
				}						
				this.lblImages.get(index).setText("image");
				DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
				Date d = df.parse(w.getDate());
				System.out.println("date: "+ w.getDate());
				@SuppressWarnings("deprecation")
				int i = d.getDay();
				String day;
				switch(i){
				case 0:
					day = "Sun"; break;
				case 1:
					day = "Mon"; break;
				case 2:
					day = "Tue"; break;
				case 3:
					day = "Wed"; break;
				case 4:
					day = "Thu"; break;
				case 5:
					day = "Fri"; break;
				case 6:
					day = "Sat"; break;
				default:
					day = "Err";
				}
				this.lblDays.get(index).setText(day);

				this.lblDates.get(index).setText(w.getDate());
				this.lblRains.get(index).setText("PPT: "+w.getPrecipMM() + "mm");
				this.lblClouds.get(index).setText(w.getWeatherDesc());
				String speed="";
				if(unitSpeed.equals("km")){
					speed = w.getWindspeedKmph()+" km/hr";
				}
				else{speed = w.getWindspeedMiles()+" mile/hr";}

				this.lblWinds.get(index).setText("Wind: "+speed);
				this.lblWindDirections.get(index).setText(w.getWinddir16Point());
				
				Image imag = null;
				   try {
				       //Read from a URL
					   System.out.println("w " + w.getWeatherIconUrl());
				       URL aurl = new URL(w.getWeatherIconUrl());
				       imag = ImageIO.read(aurl);
				   } catch (IOException e) {
				   }
				   this.lblImages.get(index).setIcon(new ImageIcon(imag));
				
			}


		}
		catch (Exception ex){
			System.err.println(ex.getMessage());
		}
	}

	private static void createAndShowGUI(WeatherInterface ws) {
		WeatherDialog frame = new WeatherDialog();
		frame.sws = ws;
	}

	public static void runDialog(final WeatherInterface ws) {
		// Schedule a job for the event-dispatching thread:
		// creating and showing this application's GUI.
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				createAndShowGUI(ws);
			}
		});
	}

	/*
	     btnGo = new JButton("Go");
panel.add(btnGo);

btnGo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
String chosencity = "Toronto";
ShowWeather(chosencity);
}
}
);
	 * 
	 * */
	// Variables declaration - do not modify
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JMenu jMenu1;
	private javax.swing.JMenu jMenu2;
	private javax.swing.JMenuBar jMenuBar1;
	private javax.swing.JMenuItem jMenuItem1;
	private javax.swing.JMenuItem jMenuItem2;
	private javax.swing.JMenuItem jMenuItem3;
	private javax.swing.JMenuItem jMenuItem4;
	private javax.swing.JMenuItem jMenuItem5;
	private javax.swing.JLabel lblCloud;
	private javax.swing.JLabel lblCloud0;
	private javax.swing.JLabel lblCloud1;
	private javax.swing.JLabel lblCloud2;
	private javax.swing.JLabel lblCloud3;
	private javax.swing.JLabel lblCondition;
	private javax.swing.JLabel lblCurrentImage;
	private javax.swing.JLabel lblDate0;
	private javax.swing.JLabel lblDate1;
	private javax.swing.JLabel lblDate2;
	private javax.swing.JLabel lblDate3;
	private javax.swing.JLabel lblDay0;
	private javax.swing.JLabel lblDay1;
	private javax.swing.JLabel lblDay2;
	private javax.swing.JLabel lblDay3;
	private javax.swing.JLabel lblHumidity;
	private javax.swing.JLabel lblImage0;
	private javax.swing.JLabel lblImage1;
	private javax.swing.JLabel lblImage2;
	private javax.swing.JLabel lblImage3;
	private javax.swing.JLabel lblMaxtemp0;
	private javax.swing.JLabel lblMaxtemp1;
	private javax.swing.JLabel lblMaxtemp2;
	private javax.swing.JLabel lblMaxtemp3;
	private javax.swing.JLabel lblMintemp0;
	private javax.swing.JLabel lblMintemp1;
	private javax.swing.JLabel lblMintemp2;
	private javax.swing.JLabel lblMintemp3;
	private javax.swing.JLabel lblPressure;
	private javax.swing.JLabel lblRain0;
	private javax.swing.JLabel lblRain1;
	private javax.swing.JLabel lblRain2;
	private javax.swing.JLabel lblRain3;
	private javax.swing.JLabel lblTemp;
	private javax.swing.JLabel lblVisibility;
	private javax.swing.JLabel lblWind;
	private javax.swing.JLabel lblWind0;
	private javax.swing.JLabel lblWind1;
	private javax.swing.JLabel lblWind2;
	private javax.swing.JLabel lblWind3;
	private javax.swing.JLabel lblWindDirection0;
	private javax.swing.JLabel lblWindDirection1;
	private javax.swing.JLabel lblWindDirection2;
	private javax.swing.JLabel lblWindDirection3;
	private javax.swing.JPanel panel0;
	private javax.swing.JPanel panel1;
	private javax.swing.JPanel panel2;
	private javax.swing.JPanel panel3;
	private javax.swing.JPanel panelCurrentCondition;
	private javax.swing.JPanel panel5;
	private javax.swing.JButton btnChange;
	
	// End of variables declaration
	@Override
	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowClosing(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeactivated(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub
		chosencity = "Toronto";
		ShowWeather(chosencity);
		System.out.println("im in windowopened action listener in weatherdialog.java");
	}



	@Override
	public void itemStateChanged(ItemEvent e) {
		// TODO Auto-generated method stub
		
	}



	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == btnChange){
			//change unit
			if(unitTemp.toLowerCase().equals("c")){ 
				this.unitTemp = "f";
				this.unitSpeed = "Mile";
				this.btnChange.setText("Change to Metric System");
			}
			else{
				this.unitTemp = "C";
				this.unitSpeed = "km";
				this.btnChange.setText("Change to US System");
			}
			System.out.println(this.unitTemp +" " + this.unitSpeed);
			this.ShowWeather(chosencity);
		}
		else if(e.getSource() == jMenuItem1){
			//about 
			JOptionPane.showMessageDialog(this,"Weather Anywhere v1.0.0","About",JOptionPane.PLAIN_MESSAGE);
			
		}
		else if(e.getSource() == jMenuItem2){
			//help
			JOptionPane.showMessageDialog(this,"Weather Anywhere v1.0.0\n\nTo search for a particular city. Select File>Location Setup. \nType the city name and press search.\n\nTo change the unit from metric to US or vice versa, click the button in\n the bottom of the main screen.","Help",JOptionPane.PLAIN_MESSAGE);
		}
		else if(e.getSource() == jMenuItem3){
			//call location here
			DialogSetLocation dialogSetLocation = new DialogSetLocation(new JFrame(), true);
			dialogSetLocation.swss = this.sws;
			dialogSetLocation.setLocation(300,400); //todo
			dialogSetLocation.setVisible(true);
			this.chosencity = dialogSetLocation.chosencity;
			this.ShowWeather(chosencity);
		}
		else if(e.getSource() == jMenuItem4){
			//call options here
		}
		else if(e.getSource() == jMenuItem5){
			//call exit here
			this.setVisible(false);
			this.dispose();
			System.exit(0);
		}
	}

}