0% found this document useful (0 votes)
7 views2 pages

Sheet #8 (Java)

Uploaded by

Amgd Talal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Sheet #8 (Java)

Uploaded by

Amgd Talal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Computer Science Division 3rd Level Students - CS

Department of Mathematics Course: COMP 301


Faculty of Science Date: November 13th, 2021

Sheet 8
Exercise 1:
Design a Java GUI program that contains a button and a text area. The program
should display appropriate messages (inside the text area) describing the status of
clicking on the button (e.g. left or right click, how many clicks, the name of any
special keys pressed while clicking).

Exercise 2:
Design a Java GUI program that whenever the user moves the mouse over the
frame the program gives the position of the mouse (both relative to the screen and
to the window).

Exercise 3:
Design the following frame (Simple Painter) which is a simple drawing program.

The user has first to pick the color he wants from the shown RadioButtons, then
choose the shape he wants to draw from the ComboBox (containing the 3 options:
Line, Square or Circle).
The selected shape is drawn with the selected color when the user clicks by the
mouse on any place in the panel (white area) starting from the point the user clicks
on it.
Note that: For the square and the circle draw them with fixed size (80×80), but for
the line pick its starting point when the mouse is pressed and pick the ending point
when the mouse is released.
Computer Science Division 3rd Level Students - CS
Department of Mathematics Course: COMP 301
Faculty of Science Date: November 13th, 2021

Hint:
Use the following methods from the MouseEvent class
• getButton ( )
• getClickCount ( )
• getModifiers ( )
• getMouseModifiersText ( )
• getSource ( )
• getX ( )
• getY ( )
• getXOnScreen ( )
• getYOnScreen ( )

You might also like