import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; /** * Main program for testing Rawbutton's */ public class Main extends JFrame implements MouseListener { public static void main (String [] args) { java.awt.EventQueue.invokeLater (new Runnable() { public void run() { new Main (); } }); } private ArrayList buttons = new ArrayList(); public Main () { // Window setup setSize (500, 500); setLayout (new FlowLayout()); setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); addMouseListener (this); // Create some Rawbutton's for testing buttons.add (new Rawbutton ("Push me", 100, 100)); buttons.add (new Rawbutton ("Me too", 300, 300)); // And a CircleButton buttons.add (new CircleButton ("Circle", 100, 250)); setVisible (true); } /** * Catch our paint callback and pass to our "components" * NB Swing calls paint() but not paintComponent() for this case. */ public void paint (Graphics g) { super.paint(g); for (Rawbutton b: buttons) b.draw (g); } /** * Catch our mouse callback and call each of our "components" to * offer them the input */ public void mousePressed (MouseEvent event) { for (Rawbutton b: buttons) b.domouse (event.getPoint().x, event.getPoint().y); } /** * Remaining required MouseListener methods */ public void mouseClicked (MouseEvent event) {} public void mouseReleased (MouseEvent event) {} public void mouseEntered (MouseEvent event) {} public void mouseExited (MouseEvent event) {} }