Mercurial > hg > ristipolku
view game/IDMWidget.java @ 49:e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 22 Feb 2011 10:52:08 +0200 |
parents | |
children | 496e616ff09d |
line wrap: on
line source
/* * Ristipolku IDM base widget * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org> */ package game; import java.awt.*; import java.awt.event.*; public class IDMWidget { int keyCode; public IDMWidget() { keyCode = -1; } public void paint(Graphics2D g) { } public boolean contains(Point pos) { return false; } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { if (contains(e.getPoint())) { clicked(); } } // Generic key handler public boolean keyPressed(KeyEvent e) { if (e.getKeyCode() == keyCode) { clicked(); return true; } else return false; } public void clicked() { } }