Building A GUI-based Event Driven Application

Building A GUI-based Event Driven Application - COP 3330:...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 3330: (Event-driven Programming) Page 1 © Dr. Mark Llewellyn COP 3330: Object-Oriented Programming Summer 2011 Building A GUI-based Event Driven Application Department of Electrical Engineering and Computer Science Computer Science Division University of Central Florida Instructor : Dr. Mark Llewellyn markl@cs.ucf.edu HEC 236, 407-823-2790 http://www.cs.ucf.edu/courses/cop3330/sum2011
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP 3330: (Event-driven Programming) Page 2 © Dr. Mark Llewellyn A Sample GUI This set of notes on GUIs and event-driven programming is devoted exclusively to developing a GUI-based event- driven program that calculates the wind chill temperature for a user-specified temperature and wind speed. – Wind chill is the temperature perceived by a person when taking into account the actual air temperature and the speed of the win. It is similar to a more popular term in Florida which is the heat index that considers the actual air temperature and the humidity (program assignment #1). You can use the GUI we develop this winter when you go skiing. – There are several different formulas available for calculating wind chill. The one in our program is used by the U.S. National Weather Service and is only valid for wind speeds in excess of 4 mph.
Background image of page 2
COP 3330: (Event-driven Programming) Page 3 © Dr. Mark Llewellyn What the GUI Should Look Like
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP 3330: (Event-driven Programming) Page 4 © Dr. Mark Llewellyn Components of the GUI • Compared to a console based application program, a GUI has many more objects to consider. A GUI program also has to deal with the interactions of its graphical components. – For example, whenever a user clicks the WindChillGUI calculator run button, the button dispatches a signal. The GUI must have a listener for that signal that causes the current temperature and windspeed data entry values to be obtained, the WindChillGUI to be calculated, and the result of that computation to be assigned to the WindChillGUI temperature entry area.
Background image of page 4
COP 3330: (Event-driven Programming) Page 5 © Dr. Mark Llewellyn Swing API Classes in the WindChillGUI Window Title bar of JFrame instance. The JFrame contains 8 GUI elements This line is a single JTextArea instance These three lines all contain a JLabel and a JTextField instance JButton instance
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP 3330: (Event-driven Programming) Page 6 © Dr. Mark Llewellyn UML For WindChillGUI Class WindChillGUI -WINDOW_WIDTH : int = 440 //GUI width -WINDOW_HEIGTH : int = 235 //GUI height -FIELD_WIDTH : int = 20 //20 characters -AREA_WIDTH:int = 40 //40 characters -LAYOUT_STYLE : FlowLayout //layout manager -LEGEND:string = “This WindChillGUI …greater than 4 mph.” -window: JFrame //main GUI window -legendArea: JTextArea //area for the Legend – set 2 rows x AREA_WIDTH -fahrTag: JLabel //temperature input box label -fahrText: JTextField //input box for temperature -windTag: JLabel // wind speed input box label -windText: JTextField //input box for wind speed -chillTag: JLabel //wind chill output box label -chillText: JTextField
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/21/2011 for the course COP 3330 taught by Professor Staff during the Summer '08 term at University of Central Florida.

Page1 / 52

Building A GUI-based Event Driven Application - COP 3330:...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online