Skip links

Java GUI代写|CPSC 210 Design GUI

这是一个加拿大的Java Swing GUI设计作业代写


description of the project structure

Phase 3 of the term project is worth 35% of your overall project grade.

code that you have written yourself since the start of this term (you must not make use of any code that you have written in the past) code found in or based on any of the projects that we present to you in lecture during the term, provided you insert a comment into your code to attribute the source

Please ensure that you do not provide other students with access to your code. By doing so, you risk enabling academic misconduct for which you will be held accountable. Typically, the same grade penalty is applied to the student who enabled access to their code, as to the student who used the code.

If you find the project challenging, ask for help from a course instructor or from one of the TAs assigned to the course this term.

Do not be tempted to copy code from someone else and do not, under any circumstances, allow another student access to your code in any way.

General Requirements

You should commit and push your code to GitHub after completion of each task, if not more frequently. By pushing your code to GitHub you are effectively making a backup of your work which you’ll be able to retrieve if anything happens to the code on your laptop.

All code must be appropriately documented:

each class should have a class-level comment (that appears just before the class declaration) to describe the information that the class represents every method must be documented with requires, modifies and effects clauses, as appropriate (note that simple setter and getter methods, and test methods, do not have to be documented)

You code must adhere to our style guidelines. Note that for the term project, the maximum method length has been increased from 20 to 25 lines.

That said, there may be some cases where it does not make sense to decompose a method whose length is greater than 25 lines. In such cases, you may include an @SuppressWarnings(“methodlength”) annotation on the line immediately preceding the method header. This instructs checkstyle not to apply the method length restriction to that particular method. You should always check with your TA before using this annotation, as any mis-use will result in a grade penalty. Note that AutoTest will list all the places in your code where the annotation is used.

Main Tasks

In Phase 3 and, indeed, all future phases of the term project, you will be working with the same repository that was provided to you for Phase 1.

This phase of the term project involves a significant amount of work. You are expected to make steady progress and commit working code to your repository each week. The previous statement will be taken into account when evaluating requests for extensions due to technical problems or other life events.

You will need to do some research and learn how to develop a graphical user interface on your own. This is a topic that we do not teach in the video or in lecture but you have all the background and tools that you need to succeed in this task. It is important for any software engineer to attain the skills necessary to successfully use a new library or framework. We realize that this task is challenging, so your TAs and instructors will be available to help out if you get stuck. However, there’s a limit to how much help we can provide if everyone leaves it to just 2 or 3 days before the deadline. We’ve given you a significant amount of time to complete this task – please use it wisely.

Task 1

If you have not done so already, please ensure that you have committed your Phase 2 code, pushed it to GitHub and requested a grade from AutoTest for your Phase 2 deliverables. We then have a record of the work that you completed during Phase 2, so that you may start work on Phase 3.

Task 2

In this phase of the term project, you are not required to add new user stories for your term project, although you may do so if you wish. However, you are not allowed to remove any existing user stories or simplify them.

If you choose to add any new user stories or add to any of the existing user stories, please commit and push the revised file to GitHub.

Task 3

In this phase, you will need to do some research and learn how to develop a small graphical user interface (GUI) on your own using the Java Swing library (you must not use any other framework for developing your user interface).

All the code related to your GUI must be written in the ui package. As user interface testing is quite challenging, you are not required to design tests for any of the code directly related to your user interface.

You are not required to support all your user stories in your GUI but you are obviously free to do so, if you wish. However, you must provide support for the following user stories:

“As a user, I want to be able to add multiple Xs to a Y”, where X and Y are classes that you have designed as part of your application. Your GUI must include a panel in which all the Xs that have already been added to Y are displayed. You are also required to implement two related events. For example, you could have a button or menu item that can be used to add an X to a Y, and another button or menu item that displays a subset of the Xs that satisfy some criterion specified by the user. Note that these are just examples – you are free to adapt these events for your particular application but the events that you implement must be somehow related to the Xs and Y.

“As a user, I want to be able to load and save the state of the application” OR “as a user, I wanted to be prompted with the option to load data from file when the application starts and prompted with the option to save data to file when the application ends”. If you go with the first option, you could have buttons or menu items that the user can click when they want to load/save data to/from file. If you go with the second option, you could have pop-up windows that give the user the option (using Yes/No buttons) to load data when the application starts and to save it when the application ends.

Your GUI must also include a visual component, such as displaying an image when an event occurs, displaying an image in a splash screen when your application starts, or displaying a graph to represent some aspect of the user’s data. Note that painting panels, buttons and menu items in different colours does not count. Please see the grading scheme below for further details.


Start with one of the GUI projects you’ve already seen in CPSC210. SpaceInvaders, RobustTrafficLights, AlarmSystem and DrawingPlayer all have different Swing GUIs that you could use as starting points.

If you want elements that aren’t used in those projects, or just want to see what else is possible, visit:

This tutorial includes zipped projects that you can download and run, most of which are fairly small and focus on just one or two GUI elements. You may want to use one of these demos as a starting point, or try to incorporate elements from them into your own project. If your project works with lists (e.g. a ToDoList application), you’ll find the list demos are perfect starting points.

Another fairly straightforward example can be found here: This application illustrates the very important concept of event handling. When the user clicks a button, moves or drags the mouse, or selects on option from a menu an event occurs to which we will want to respond. We do so by writing an event handler. We’ve copied the code below (changed the name of the class and added some comments, but otherwise it’s from the stack overflow answer). Copy and paste it into a new Java application, and then run it:

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class LabelChanger extends JFrame implements ActionListener {
private JLabel label;
private JTextField field;

public LabelChanger() {
super(“The title”);
setPreferredSize(new Dimension(400, 90));
((JPanel) getContentPane()).setBorder(new EmptyBorder(13, 13, 13, 13) );
setLayout(new FlowLayout());
JButton btn = new JButton(“Change”);
btn.addActionListener(this); // Sets “this” object as an action listener for btn
// so that when the btn is clicked,
// this.actionPerformed(ActionEvent e) will be called.
// You could also set a different object, if you wanted
// a different object to respond to the button click
label = new JLabel(“flag”);
field = new JTextField(5);

//This is the method that is called when the the JButton btn is clicked
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(“myButton”)) {

public static void main(String[] args) {
new LabelChanger();

You can find a more general introduction to event handling here:

along with several examples of different kinds of events and their corresponding handlers. You may want to look through this tutorial for examples to illustrate the kinds of events that you want to handle in your project.

Leave a comment