Skip to main content

First define the GUI class which extends Jframe

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
Introduction
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.
GENERAL INSTRUCTIONS
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
Add

Subtract


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:
// *******************************************************
getContentPane().setLayout(null);
setTitle(-Assignment PartA-);
// *******************************************************
String text = text1.getText();
try
{
val1 = Double.parseDouble(text);

}
catch (NumberFormatException e)
{
val1=0;
rc=false;
JOptionPane.showMessageDialog(null, -Enter a valid double precision number please-,
- First Number Error -,
JOptionPane.ERROR_MESSAGE);
}
// *******************************************************
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)));}
else
{displayText4.setText(-0-);}

}
}
// *******************************************************
int posX =260;
JButton buttonAdd = new JButton(-Add-);
buttonAdd.setLocation(posX,30);
buttonAdd.setSize(110,20);
buttonAdd.addActionListener(new bAddAction());
getContentPane().add(buttonAdd);
Logo
.
CLICK HERE TO ORDER 100% ORIGINAL PAPERS AT PrimeWritersBay.com

Comments

Popular posts from this blog

Why was this movie important to hollywood? What was the feeling of it, the colors, techniques, theme, director, style, music, anything! What was special about Alfred Hitchcock and this film?

  Directions For this assignment, you will need to choose a topic or person from any of the various eras, movements or decades that we've discussed this semester and do a presentation on them using any media format you choose. (IM CHOOSING THE MOVIE PSYCHO-    Why was this movie important to hollywood? What was the feeling of it, the colors, techniques, theme, director, style, music, anything!  What was special about Alfred Hitchcock and this film? The subject matter doesn't have to be limited to an actor, director or filmmaker, but  the topic of your presentation could be on the inventions of any of the equipment, editing or filming techniques that you've learned about.  Basically, you can pick an area to cover and do your presentation on that.  The point is that you take a deeper dive into the subject by exploring information about it that may not have been  covered in this course.  It does have to...

Account Cost Systems and Cost Behaviors

  ACC501 Account Cost Systems and Cost Behaviors You are applying for a managerial position at an innovative and rapidly growing company. This is a dynamic company that wants an individual who adds value to the organization. Managers at this company wear many hats, so the position requires managing products, people, and financial aspects of running the company. As part of the interview process, you are required to make a presentation covering four different topics, one per module for this course. You choose the company and the new product that you want to showcase in your presentation. It can be real or fictitious (based on an industry). This is for background purposes only. The presentation is to showcase your abilities and what you can contribute to the organization. IBIS World (access on the Trident Portal through the Online Library > Additional Library Resources > IBISWorld link) and BizStats have estimates of cost of goods sold ...

Starting with this provided code, add the following functionality

1.Starting with this provided code, add the following functionality: Replace hardcoded strings “Zero”, “One”, “Two”, “Three” in the ArrayList based on user typed input (use Scanner or JOptionPane classes). The user will be prompted for the String to be stored in the ArrayList and then hit enter. The user will be able to continue to add items to the ArrayList until they just hit enter without typing anything. Once the user does this (hits enter without typing anything), the program will display all of the elements of the ArrayList, both the index and String values, in a table. It will do this via a single loop making use of an iterator method. 2. Starting with this provided code, add the following functionality: Use a Try/Catch block so that the exception is caught and the program exits a bit more gracefully. Save this file as TryCatch.java. (Be sure to rename the Public Class accordingly.) Starting with the provided code again (without the Try/Catch block), fix the code so that ...