practice-Graphics

practice-Graphics - (radius = 2 pixels that shows the...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 205 - Fall 2008 – Practice Graphics First Name (Print)___________________ Last Name _________________Date____ 1. Complete the code in the Shapes class so that it will generates the applet showing the graphics below. It contains five squares in blue, and four arcs in red. The size of this applet is 400 by 400. Each square is twice as large as the square below it except two squares at the right bottom corner that are of the same size. import javax.swing.*; import java.awt.*; public class Shapes extends JApplet { public void paint (Graphics page) { setSize(400,400);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2. Complete the code in the PointPanel class such that each time a user presses a mouse button, the coordinate of the point that was pressed appears in red color together with a small dot
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (radius = 2 pixels) that shows the pressed point. When a user presses a mouse button in another place in the panel, it should show only the current coordinate, and the previously pressed coordinate should disappear. The background of this applet is yellow. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MouseApplet extends JApplet { public void init() { PointPanel myPoint = new PointPanel(); getContentPane().add(myPoint); setSize(250,150); } } public class PointPanel extends JPanel { private Point pt; public PointPanel() {...
View Full Document

{[ snackBarMessage ]}

Page1 / 3

practice-Graphics - (radius = 2 pixels that shows the...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online