CS 103

Outline of Material for Test 3


Test 3 will be completely different from the other two tests. Tests 1 and 2 were designed to test your knowledge and understanding of the Java language. Test 3 will test your ability to apply what you know. This test will be open book, open notes. You may use any references, including the CS 103 web page during the test.

In Test 3 you will be given a programming assignment. You will create a new project in Eclipse and build the program to the exact specifications as described. An example, not the one that will be on the test, is shown below.

At the end of the class you will be required to create a folder on your thumb drive with your name on it. For example: John Doe would create a folder and name it jdoe. Into this folder you will copy all source code files (those with the .java extension) from the test program and an executable .jar file which you created from your test program. This folder and all contents will then be copied to the K drive.

The test requirements may ask you to implement in your program any of the following GUI widgets: JFrame, JPanel, JButton, JTextField, JRadioButton, ButtonGroup, JCheckBox, JList, JScrollPane, JComboBox, or JSlider. Buttons, radio buttons, check boxes and combo boxes will be required to implement an ActionListener. A JList will be required to implement a ListSelectionListener. Each item may or may not be required to set a particular background color.

Sample Test 3

Design and implement a program in Java that meets ALL of the following requirements. Use the blank at the beginning of each requirement to check off each completed item.
  • _____ 1. Create a new project in Eclipse and call it Test3Project.
  • _____ 2. Add a class to the project and call it Test3Main. This class must have the following properties:
    1. _____ Place the main() function in this class.
    2. _____ Make this class a sub-class of JFrame.
    3. _____ Set the size to 320 pixels wide by 240 pixels high.
    4. _____ Set the location on the screen to 100 pixels across and 100 pixels down.
    5. _____ Set the title of the JFrame to Your Name - Test 3.
    6. _____ Set the default close operation to EXIT_ON_CLOSE.
    7. _____ Place in a comment at the top of the source file the following.
      //--------------------------------------------------------------------------
      // This program is entirely my work and was completed during the time limits
      //  of the test.
      //
      // Type your name here
      //--------------------------------------------------------------------------
      
      Files without this comment will not be accepted for credit.

  • _____ 3. Add a JPanel reference variable to the Test3Main class and create a new JPanel in the class constructor. You may name the JPanel anything you wish. This panel must have the following properties:
    1. _____ Set the size to 320 pixels wide by 240 pixels high.
    2. _____ Set the location to 0, 0.
    3. _____ Set the background color to DARK_GRAY.
    4. _____ Set the layout to null.
    5. _____ Add the panel to the JFrame's content pane.
  • _____ 4. Add two JButtons reference variables to the Test3Main class and create two new JButtons in the class constructor. You may name the JButton variables anything you wish. This buttons must have the following properties:
      Button 1
    1. _____ Set the button text to Red Button.
    2. _____ Set the size to 100 pixels wide by 20 pixels high.
    3. _____ Set the location to 50, 50.
    4. _____ Set the background color to RED.
    5. _____ Give the button a RAISED border.
    6. _____ Add an action listener to the button that will print "Red button clicked" in the text field below when the button is clicked.
    7. _____ Add the button to the JPanel described above.
      Button 2
    1. _____ Set the button text to Blue Button.
    2. _____ Set the size to 100 pixels wide by 20 pixels high.
    3. _____ Set the location to 170, 50.
    4. _____ Set the background color to BLUE.
    5. _____ Give the button a RAISED border.
    6. _____ Add an action listener to the button that will print "Blue button clicked" in the text field below when the button is clicked.
    7. _____ Add the button to the JPanel described above.
  • _____ 5. Add a JTextField reference variable to the Test3Main class and create a new JTextField in the class constructor. You may name the JTextField variables anything you wish. This JTextField must have the following properties:
    1. _____ Set the size to 260 pixels wide by 20 pixels high.
    2. _____ Set the location to 20, 100.
    3. _____ Set the editable property to false.
    4. _____ Set the background color to WHITE.
    5. _____ Add the text field to the JPanel described above.
  • _____ 6. Compile and run your program to be sure it works as it should.
  • _____ 7. Create an executable JAR file from your program. You may name the JAR file anything you wish.
  • _____ 8. On your thumb drive create a new folder and name it with your name, for example: John Doe would create a folder and name it jdoe.
  • _____ 9. Copy both the .java source file and the executable JAR file into this folder then copy the folder onto the K drive.
Note: The instructor will be monitoring the K drive during class and will immediately copy your folder from K to his thumb drive and delete the folder from drive K. Any folders appearing on drive K after the end of class or from anyone who has already left class will not be accepted.


The results of the above sample test will create a window as shown below. It may not be pretty, but it does meet all the requirements.