Recent Question/Assignment

University of Canberra
Faculty of Education, Science, Technology and Mathematics
4483 Software Technology 1 and
8995 Software Technology 1 G
Semester 2, 2017
Assignment Part A (part 1 of 3)
(6% of Grade)
Due: During your normal tutorial in Week 13 (Starting 30th October 2017). Demonstrate it for a demonstration and immediate mark) or submit on Moodle by Friday 3rd November.
If you do a demonstration to your tutor you do not need to submit it to Moodle.
Basic Swing Form
This part of your main assignment should be done individually. This assignment consists of writing a program and demonstrating it or submitting it on Moodle.
NOTE: while you can do this using drag and drop in eclipse or some other java development environment you should be warned that; I will put coding questions in the exam that assume you wrote this swing form yourself manually coding the listeners and attaching them to buttons. You are unlikely to learn how to do this if you use drag and drop GUI builders.
Write a simple swing form that has the following features and looks (more or less) like the following:

It has three buttons, each of which does one thing; Add, Subtract, Concatenate.
Here are examples of each function


Concatenate (example 1)

Concatenate (example 2)

Marking Rubric
No Submission Zero Marks
Form Displays with no features working 2 Marks
Add button works 4 Marks
Add and Subtract buttons work 5 Marks
Add, Subtract and Concatenate buttons work 6 Marks
You Tutor can mark it quickly and on the spot with a simple demonstration or you can submit it to Moodle with the code and a cover sheet and screenshots of all 3 functions (as in my example above, show two different examples of concatenate):
It’s fairly Straightforward to code if you have done the Swing Tutorial 1
Hints :
1. First define the GUI class which extends Jframe
2. Set the frame size
3. Set it to visible
4. Add the 3 or 4 JLabels (I used a JLabel for ===== which is optional)
5. Test it
6. Add the 2 JTextField (input boxes)
7. Test it
8. Add the 3 buttons
9. Test it
10. Write 1 listener class for Add
11. Connect the listener to the button
12. Test it
13. Write 2 more listener classes for Subtract and Concatenate
14. Connect the listener to the button
15. Test it
16. Drink Vanilla coke (optional step)
17. Fix formatting of the output
18. Add a title to jframe
19. Tidy it up
20. Test it
21. Show your tutor (get 6 easy marks)
Below are some useful code fragments:
// *******************************************************
setTitle(-Assignment PartA-);
// *******************************************************
String text = text1.getText();
val1 = Double.parseDouble(text);

catch (NumberFormatException e)
JOptionPane.showMessageDialog(null, -Enter a valid double precision number please-,
- First Number Error -,
// *******************************************************
public class bAddAction implements ActionListener
public void actionPerformed (ActionEvent event)
///// -----------------

////// Lines deleted here that parsed the JTextFields into val1 and val2
///// -----------------
if (rc)
{displayText4.setText(String.format(-%12.4f-,(val1 + val2)));}

// *******************************************************
int posX =260;
JButton buttonAdd = new JButton(-Add-);
buttonAdd.addActionListener(new bAddAction());

// *******************************************************

Looking for answers ?