Uploading Instructions: A Source Code

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Assignment No.

02
Fall 2014
CS506- Web Design and Development

Total Marks: 20
Due Date:10/12/14

Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit if:
o
o
o
o
o

The assignment is submitted after due date.


The submitted assignment does not open or file corrupt.
The assignment is fully or partially copied from (other student or ditto copy from handouts or internet).
Student ID is not mentioned in the assignment File or name of file is other than student ID.
The assignment is not submitted in .java format.

Uploading instructions
You have to upload only a source code file with (.java) extension. Assignment in any other format
(extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in
.doc (Word document) or .txt files or .exe file, no reward will be given in any case.

Note: Use Notepad or Notepad++ , or NetBeans for coding and JDK package for java source code compilation
and running (A video tutorial of JDK installation and configuration is given in course download section)

Objective
The objective of this assignment is
o To understanding of User Graphical Interface, layout mangers, frames and Event Handling concepts in
java programs.

Problem Statement:
You are required to write a java program which handles the MouseEvent by implementing MouseListener
interface.
Detailed Description:
Develop a GUI component and set the layout using FlowLayout manger. The program should have two text
fields used for displaying your name and VUID as a default text. There should also be two labels in your GUI.
Following four controls should be used in your GUI application.

Student Name (JLabel)


VU ID(JLabel)
Student_Name (JTextField)
VU_ID (JTextField)

Following is the behavior of your GUI Application which handles the Mouse Events program.

When mouse enter the boundary of frame window default text should be appeared in the
respective textfields i.e. your name and VUID
When mouse exit the boundary of frame window default text should be removed from the text
fields, it sets empty.

For this your class has to implement the MouseListener interface, MouseListener interface has following five
abstract methods.
public interface MouseListener {
public void mousePressed (MouseEvent me);
public void mouseClicked (MouseEvent me);
public void mouseReleased (MouseEvent me);
public void mouseEntered (MouseEvent me);
public void mouseExited (MouseEvent me);
}
But your class will implement the logic in last two methods,
public void mouseEntered (MouseEvent me);
You will write the logic in above method when mouse enter the frame window i.e. setting of text in respective
text fields
public void mouseExited (MouseEvent me);
You will write the logic in above method when mouse leaves the frame window i.e. clearing of text in respective
text fields
Remaining methods will have an empty body.

Set the frame size width 300 and height 200.


You can use the setText(String) method for setting of text of Two JTextField. Use your name and your

VUID to store values in these two text fields


When you exit from the program, it should close the frame.

Sample Output:
Mouse enter the boundary of frame window

Mouse exit the boundary of frame window

Lectures Covered: This assignment covers Lecture # 10-13


Deadline Your assignment must be uploaded/submitted at or before 10/12/2014.
For any query about the assignment, contact at cs506@vu.edu.pk
GOOD LUCK

You might also like