Files
GTSchoolShit/CS1322/p6/Extra Credit/p6ex.nfo.txt
2025-06-07 01:59:34 -04:00

112 lines
4.2 KiB
Plaintext

CS1322: Lab #15 - Spring 2002.
Program Title: Complete the Calculator GUI.
Files Provided
========================================================================
o lab15.nfo
o CalculatorGUI.java - The View (the only file you edit).
o EventHandler.java - The Control.
o Calculator.java - The Model.
Introduction
========================================================================
Its time to learn about Graphical User Interfaces. In this lab, you
will be using the Swing GUI library to create a user interface. It
will focus on GUI layout and component creation. You are given a
working EventHandler that will handle your button presses and a model
that will actually do the calculations. You will need to Complete
CalculatorGUI so that the GUI components are displayed to the
specification stated later in this nfo file.
Excellent References:
o The JAVA API
http://java.sun.com/products/jdk/1.3/docs/api/index.html
o The JAVA Tutorial
http://java.sun.com/docs/books/tutorial/
Also, lab15.intro is an excellent source for learning besic GUI
information. Anyone who has not done Swing GUI programming before
should go through its examples (you are responsible for that
information).
You will probably need to visit the API to properly finish this lab
and are expected to be able to do this.
The Project
========================================================================
It is your job to create the components for a CalculatorGUI, so that
one can use the calulator.
-----------------------
|cs1322 Lab15 |X| The guiFrame should say "cs1322 is fun!"
|-----------------------| The numberLabel should say "Calculator"
| | There should be 10 numberedButtons
| Calculator | numberedButtons[0 - 9] = "0" - "9"
| | There should be 6 operationButtons
|-----------------------| operationButtons[0] = "Clr"
| | | | | operationButtons[1] = "="
| 1 | 2 | 3 | + | operationButtons[2] = "+"
| | | | | operationButtons[3] = "-"
|-----------------------| operationButtons[4] = "*"
| | | | | operationButtons[5] = "/"
| 4 | 5 | 6 | - | The empty spots by "0" should be empty JPanels
| | | | |
|-----------------------| contentPane should be a JPanel with a BorderLayout
| | | | | operationPanel should be a JPanel with a
| 7 | 8 | 9 | * | GridLayout thats 1 row by 2 columns.
| | | | | buttonPanel should be a JPanel with a GridLayout
|-----------------------| thats 4 by 4.
| | | | |
| | 0 | | / | contentPane should become guiFrame's content pane.
| | | | | numberLabel should be in the North of contentPane.
|-----------------------| buttonPanel should be in the Center of contentPane.
| | | operationPanel should be in the South.
| Clr | = | "Clr" and "=" should be in operationPanel.
| | | "1" - "9", "+" - "/" should be in buttonPanel.
-----------------------
Customizations:
The numberLabel should have its font increased by a factor of 2.0 (size * 2.0)
(you may want to do numberLabel.setHorizontalAlignment(numberLabel.RIGHT); too)
"0" - "9" should have their backgrounds changed to java.awt.Color.cyan
"=" - "/" should have their backgrounds changed to java.awt.Color.pink
"Clr" should have their backgrounds changed to java.awt.Color.yellow
Prevent all the buttons from having their focus be painted.
In CalculatorGUI:
Complete the functions:
- doMakeObjects();
- doAddObjects();
- doCustomizations();
The function doEventHandler is provided for you (this time). This
information will be the focus of lab16.
Two more functions. These functions will be used by the event
handler to update the calculator's display. The event handler needs
to be able to set the display and then read the display to do
calculations.
- getDisplay
It should return the text contained in numberLabel.
- setDisplay
It should set the text in numberLabel.
To test your code, compile the supplied files and run CalculatorGUI.
TURNIN
========================================================================
o Files to be turned in:
CalculatorGUI.java