Solution>>CIS355A Week 5 Practice GUI

Posted on : by : jsmith

$ 24.99

Program files for each of the following programs.

  1. Manage client information
  2. Draw a snowman

At the beginning of all your programs, put a comment box that includes the program name, your name, and a brief description of the program.

Program Name:
Programmer’s Name: Student Name
Program Description: Describe here what this program will do

How to submit your assignment:

  1. The programs must have the same names as the assignment title.
  2. Each Java source file (*.java) must include a corresponding class file (*.class) program as evidence of success.
  3. In addition to the program source code files and byte code files, you will document your analysis/design and testing (including screen shots) in a Lab Report.
  4. You must use a zipped folder to send your weekly assignment to the Dropbox. Do not send subfolders within your zipped folder. Place all of the .java and .class files and your lab report for the week into the one zipped folder. The zip folder should be named CIS355A_YourLastName_iLab_Week5, and this zip folder will contain all the weekly programming assignments.

STEP 1: Writing out Client Information

1)      Create the following GUI, so that when your program is running, your user can input information regarding a client and hit the save button to save the information out to a file.

Filename:  User enters a filename here (such as client.txt) which is the file to read and write.  An error message should display when Display or Save is clicked if there is no filename entered.

Save button: 

  • If no filename is entered, display error message.
  • If any data is blank, display an error message.
  • If all input is valid, data from the GUI (name, id, start balance, close balance) is saved to the file entered in Filename.  Each new client’s information should appendto the information already saved onto the file.  The data must be saved with a delimiter character of your choice between the fields (such as “|” or “#” ) so that the data in the file looks like the following example:

Charles Smith|100235|5700.75|1200.00

James Peterson|320056|349.56|4005.56

  • The data fields (name, id, start, close) should be cleared to make the next input easier.
  • Remember to close the file

Display button: 

  • Read the data in the file specified by filename (if none specified, give error message) and display a report in the CONSOLE formatted as shown below
  • You will need to use StringTokenizer to “separate” the fields based on the delimiter character in the file.
  • Remember to close the file

Client Activity Report Client Name
  Client ID
  Starting Balance
  Closing Balance XXXXXXXXX
  99999.99 XXXXXXXXX
  9999999   99999.99
  99999.99 XXXXXXXXX
  99999.99   99999.99

Grading Rubric

Standard header included 1 Must contain program name, student’s name, and description of the program
Lab Report 5 Documents analysis and design, testing with screenshots, multiple test cases
GUI is correct 5 Has correct fields and displays correctly
Data saved to file with delimiters 5 The data is written to the file and formatted correctly, appends to existing file
Error messages if no filename or if missing data 3 All input is validated before processing
GUI cleared after a Save 2 Textfields cleared for next input
Reads file using String Tokenizer to separate fields 5 The data is read from the file correctly
Report displayed in console formatted correctly 4 Data displayed in console correctly


STEP 2: Snowman!

Use the many draw methods provided to you by Java and draw a Snowman—be as creative or as basic as you would like, as long as the final result resembles a snowman. It doesn’t have to necessarily look exactly like this, but this is the minimum you should achieve with your drawing.

1) You must have at least three circles in your project.

2) You must have at least a line, a polygon, an oval, or a rectangle.

3) In addition to your snowman, you should also use drawString to draw some text.

4) Use draw or fill and the color class as you see fit.

Hint: frame.getContentPane().setBackground(; //This is the code you need to set the frame’s background color.

Have Fun!

Snowman Points Description Standard header included


Must contain program name, student’s name, and description of the program Program Compiles


Program does not have any error Program Executes


Program runs without any error Program Output


Drawing resembles a Snowman Correct use of Classes/Methods


Program contains background color, the shapes  asked for, and uses the drawString method


CIS355A Lab 5 Report


Your Name: Amit Ranga

Date:  2/5/2017

Lab Week 5


Objective/Purpose of the program


Stocks4U needs to develop an app for you to manage your stock purchases. You should be able to store a list of stock purchases, view the individual stocks, add and remove stocks.


You can code the GUI by hand or use NetBeans GUI builder interface.


The GUI should have two tabs usingJTabbedPane.

  • One tab (“Show stocks”) should have
    • a JList to display all the stock purchases;
    • a text field or label to display information about a particular stock; and
    • a JButton to remove a stock.
  • One tab (“Add stock”) should have textboxes, labels, and a button to input a stock.


Create a Stock class to manage the stock activity. It should have private instance variables of

  • company name;
  • number of shares;
  • purchase price; and
  • current price.

Create a default and parameterized constructor.

Create sets/gets for all instance variables.

Create a get method to calculate and return the profit or loss. This would be calculated as

Number of shares * (current price – purchase price).

Create toString to display the name of the stock.


As you add stocks, they are displayed in the JList.

If you select an element in the JList, the gain or loss is displayed in the label or text field.

If you select an element in the JList and click Remove, the stock is removed from the list.


You will enhance Week 4 GUI to include

  • a File menu with menu items: open, save, exit; and
  • a label to display total portfolio value.


Stock class

  • Modify the toString of Stock class to display as

“Company: qty shares” (i.e., “Apple: 10 shares”)


StockIO class

Create a StockIO class that is used to read from and write to a text file using an ArrayList.  Make sure to use a delimiter between the fields; it does not have to be the # character.  Example format of the file is:





This class should have two methods.

  • getData—reads data from file, returns data in array list of stock objects
  • saveData—writes data from an array list to the file in proper format

The file name will be an instance variable that you can set with a parameterized constructor, or with a separate method.


GUI class

Note that you will need to add an ArrayList to your GUI class to manage the data to/from the file. It will act as a parallel array to your DefaultListModel. Anytime you add a stock, you must add it in BOTH places. Anytime you remove a stock, you must remove it in BOTH places.


File—open should prompt for filename using JOptionPane, read the file and populate the JList.

File—save should prompt for filename to save data from JList to.

File—exit should exit the program.


The total value of the portfolio should be displayed at all times and updated anytime a stock is added or removed.



Describe the approach/structure of program.What classes/functions were used?