-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWeatherAppReadMe
More file actions
32 lines (29 loc) · 2.63 KB
/
WeatherAppReadMe
File metadata and controls
32 lines (29 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Our weather app consists of two components: Backend API processes, and the graphical interface.
The GetWeather.java file has a function named getWeather that accepts a single String parameter.
This parameter allows the user to input a city of their choice.
This city is added to a string containing the rest of the API weblink.
Then, a URL object is made with this string/link, and then a connection is established to this URL.
Then, in a try/catch statement
The BufferedReader class and the InputStream class is used to read and simplifythe large stream of open data/JSON from the connection to the URL.
A String variable is then created to contain the whole string of simplified data.
Using this string variable, we can grab specific values like temperature(Kelvin), the weather condition, the humidity and the wind speed, with substring methods.
Then, we return a list of strings with these pieces of data,
So this data can be used in the GUI.java file - the information can be presented in the graphical interface.
The graphical interface JFrame to create a graphical user interface.
Multiple instance variables are created to build the whole interface.
The frame, the Textfield, the labels and the button are defined here.
The contructor is right under the variables, but it doesn't contain any parameters,
As an object of the GUI class will be used later to attach an action listener to the city-submit button.
After all of the labels and add-ons are properly placed in the graphical interface, the actionPerformed method is below.
This method is triggered when the user clicks the city-submit button.
This method calls the getWeather function from the other file, and it fills a local array with these returned details
Then, the labels on the graphical interfact are set to display these individual weather details.
The user can keep entering in cities to check the weather, as the program does not end after one request.
On the graphic (called Siri) that we were going to add to the graphical interface, the class Siri is extended from the imported class Jframe.
Then, the dimensions are made for the JFrame, and it is set as visible.
Then, a JPanel is created, using the imported packages.
A method is created, which holds the information of the graphics on the screen. It contains rectangles, circles, and round rectangles.
We make these new graphic objects through what we imported.
Afterwards, we set the title to our Jpanel to "Siri Weather"
In the main method, there is SwingUtilities.invokeLater, which allows the run method to be ran.
- the siri class sucessfully runs and creates a graphic that looks like a phone, but we were unable to utilize in our weather app.