/** * @author Donald Yessick * */ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.MouseEvent; /** * Lab 13 describes methods and attributes inherited from BlueScreenTV * You need to provide implementations of these methods to override the * BlueScreenTV definitions */ public class Lab13 extends BlueScreenTV { /** * protected boolean isPowerOn * true = on, false is off * defaults to true; * * protected int channel = 1; * we have channel 1 and channel 2 * defaults to channel 1 */ /** * toString() This is called when the program needs a string TV * for example as a Window title. BlueScreenTV indicated channel or power status */ public String toString(){ return "replace this meaningless string"; } /** * This is called when the user clicks the mouse * mouseEvent has many useful methods. Try printing getX() and getY() * I started it for you. by showing you how to call it. */ public void mouseClicked(MouseEvent mouseEvent) { this.getGraphics().drawString("mouseEvent.getX(), mouseEvent.getY()", mouseEvent.getX(), mouseEvent.getY()); } /** * define what happens (state change) when the user presses the power button */ public void pushPowerButton() { // toggle protected boolean isPowerOn } /** * define what happens (state change) when the user changes channels */ public void changeChannel() { // toggle protected int channel } /** * this is called when the user starts the program * @param args */ public static void main(String[] args) { BlueScreenTV.lab13(new Lab13()); } /** * this is called when the window refreshes every 33 millisecs * it's painting over the mouse message -- how can you fix that? * perhaps you could move the drawing to here */ public void paintComponent(Graphics oldGraphics) { Graphics2D g = (Graphics2D) oldGraphics; super.paintComponent(g); } }