CountClicksPanel - { super.paintComponent(page);...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // CountClicksPanel.java Author: Lewis and Loftus / Alicia Nicoll // // Solution to Programming Project 7.10 //******************************************************************** / import javax.swing.*; import java.awt.*; import java.awt.event.*; i public class CountClicksPanel extends JPanel { private int count; public CountClicksPanel () { addMouseListener(new ClickListener()); setBackground (Color.orange); } //----------------------------------------------------------------- // Displays the number of times the mouse is pressed. //----------------------------------------------------------------- public void paintComponent (Graphics page)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { super.paintComponent(page); page.setColor(Color.blue); page.drawString("Clicks: " + count, 75, 100); } //***************************************************************** // Represents a listener for the mouse click event //***************************************************************** class ClickListener extends MouseAdapter { //-----------------------------------------------------------------// Counts the number of times the mouse is pressed. //-----------------------------------------------------------------public void mouseClicked (MouseEvent event) { count++; repaint(); } } }...
View Full Document

Ask a homework question - tutors are online