Você está na página 1de 5

ICOM 4015-Advanced Programming

Spring 2015
Instructor: Dr. Pedro Rivera
TAs: Pardeep Kumar, Orlando Nieves

Reference: Big Java

Lab 1
Introduction to Programming, Eclipse IDE
Java and work environment.

Department
of
Electrical and Computer Engineering
University of Puerto Rico at Mayagez

During the Lab:


0- Login to the computer and setting up account ( 5-10 minutes)
Instructions will be given by the lab instructors.
1- Account set up and introduction with the environment (Basic commands 5-10min).

2- Review of Eclipse (20 min)


Run the Eclipse in the lab. Understand the purpose of workspace and how to define it.
The lab instructors will give you a quick review of most important menu items

3- Hello World Applications (15-20 min)


a) From the Cheat Sheets, follow the tutorial to create a Hello World application.
Show your work to the lab instructor (30 Points).
b) From the Cheat Sheets, follow the tutorial to create a Hello World SWT
application.
a. Set the top left location of the shell to coordination (150,150).
b. Set the size of the shell to 400 and 200 pixels for the width and height,
respectively.
Show your work to the lab instructor (30 Points).

4- Make a Java Project from scratch (20 min)


- Open a new Java Project.
- Add a new class named FrameViewer
o Recall name of a class should start with a capital letter
o Make sure the method stub
public static void main(String[] args)

is automatically created

in that class.
- Add the following line
import javax.swing.JFrame;
to the beginning of the file that contains your FrameViewer Class.
- Insert the following lines
JFrame frame = new JFrame();
frame.setSize(300, 400);
frame.setTitle("My First Java Frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

inside the method main ()

- Save and run your program.


You should see the frame that you just created as depicted in Figure 1.
Important Point:
What you have done here?
- In the first line, you have created an object from data type JFrame; and, you have called the justborn object frame. If you wish, change his name to babyFrame and run your program again.
- Recall that data type JFrame can be read as class JFrame.
- In the next three lines, you have set some of the properties of your just-born object. Change these
properties and run your program again and again to see the differences.
- In the last line above, you have set an important property of your just-born object. Without this,
your object, although already born, may not be visible on the display of your computer. Just change
true to false, and run your program yet another time, to see the difference!

Show your work to the lab instructor (20 Points).


5- From your terminal, write the command cd yourFolderName.
This should update the directory path to the folder we created earlier.
Now, write the command cd src.
Finally, write the command javac YourClassFileName to compile your class.

To run your program from terminal, go to your terminal and access your project
folder once again using cd test or if you are already in the same directory just
follow next step.
Now, write java YourClassFileName. This should have your server start
listening.
Show your work to the lab instructor (20 Points).

After the Lab:


1- Install the Eclipse IDE for Java EE Developers & more features of Eclipse.
2- Investigate what widgets are and what features the swt package has.
3- Investigate important features of the swing package.
4- Investigate important features of the awt package.

Evaluating Lab 1
Write Your Section# here: ..

Você também pode gostar