CS349 User Interfaces
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Running Sample Code

We maintain a public repository of the source code shown in lectures. You are encouraged to review these projects and code snippets to help with your understanding of the course material. Additionally, you are allowed to use these samples in your assignments. If you do so, please make a comment in the code indicating which samples you used.

Here’s a short video demonstrating how to open and run samples.

Fetch a local copy of the samples

Samples are maintained in a public Git repository. To get a copy, git clone the repository URL. This command, for instance, would create a working copy of the sample code in a directory named cs349.

$ git clone https://git.uwaterloo.ca/cs349/public/sample-code.git cs349

In the samples, you should see the following directory structure. Each of the numbered folders represents a section in the course, and contains multiple projects. All projects are built using Gradle and IntelliJ and should be runnable either from the command-line or from the IDE.

cs349/
 ├── Android
 ├── Animation
 ├── Events
 ├── Graphics
 ├── Hit-Testing
 ├── Input
 ├── Layout
 ├── MVC
 ├── Responsiveness
 ├── Transforms
 ├── UndoRedo
 ├── W22OnlineLectures
 ├── Widgets
 └── readme.md

Build projects in IntelliJ

You can build and execute these projects directly in IntelliJ:

  1. File -> Open and navigate to the top-level directory containing the build.gradle file. Do NOT open a specific file, just the directory. Click Ok.

  2. After the project has loaded, open the Gradle tasks window using the (View -> Tool Windows -> Gradle) menu or the vertical Gradle tab (on the right side of the workspace). Double click on Tasks/application/run to build and run your application.

IntelliJ witih Gradle window open

HINT: After the first build for a project, you will see a new option in the build toolbar like 01.Functions [run]. Now you can use the green “play” button to build and run your application, or the “hammer” button to build it.