gui - part 3 - COP 3330: Object-Oriented Programming Summer...

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

View Full Document Right Arrow Icon
COP 3330: GUIs Page 1 © Mark Llewellyn COP 3330: Object-Oriented Programming Summer 2007 GUI Programming – Part 3 School of Electrical Engineering and Computer Science University of Central Florida Instructor : Mark Llewellyn [email protected] HEC 236, 823-2790 http://www.cs.ucf.edu/courses/cop3330/sum2007
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: GUIs Page 2 © Mark Llewellyn A Sample GUI This set of notes is devoted exclusively to developing a GUI-based event-driven program that calculates the windchill temperature for a user-specified temperature and windspeed. Windchill 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 heatindex that considers the actual air temperature and the humidity. You can use the GUI we develop this winter when you go skiing. There are several different formulas available for calculating windchill. The one in our program is used by the U.S. National Weather Service and is only valid for windspeeds in excess of 4 mph.
Background image of page 2
COP 3330: GUIs Page 3 © 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: GUIs Page 4 © 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 windchill 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 windchill to be calculated, and the result of that computation to be assigned to the windchill temperature entry area.
Background image of page 4
COP 3330: GUIs Page 5 © Mark Llewellyn Swing API Classes in the WindChill 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: GUIs Page 6 © Mark Llewellyn The Windchill GUI Program //windchill GUI //Developed: June 2007 import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Windchill implements ActionListener{ //class constants private static final int WINDOW_WIDTH = 410; //pixels private static final int WINDOW_HEIGHT = 235; //pixels private static final int FIELD_WIDTH = 20; //characters private static final int AREA_WIDTH = 40; //characters private static final FlowLayout LAYOUT_STYLE = new FlowLayout(); private static final String LEGEND = " This windchill " + "calculator is intended for wind speeds greater than 4 mph.";
Background image of page 6
COP 3330: GUIs Page 7 © Mark Llewellyn //instance variables //window for GUI private JFrame window = new JFrame("Windchill Calculator"); //legend private JTextArea legendArea = new JTextArea(LEGEND, 2, AREA_WIDTH); //user entry area for temperature private JLabel fahrTag = new JLabel("Fahrenheit Temperature"); private JTextField fahrText = new JTextField(FIELD_WIDTH);
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

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

Page1 / 53

gui - part 3 - COP 3330: Object-Oriented Programming Summer...

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

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