/* * BallFrame.java * * Created on April 21, 2005, 3:30 PM */ /** * * @author levenick */ import java.awt.*; public class BallFrame extends Frame { public static final int HT = 700; private Controller theController; Thread aThread; /** Creates a new instance of ThreadedFrame */ public BallFrame() { initComponents(); theController = new Controller(this); theController.start(); show(); setBounds(10,10,500,800); } public void paint(Graphics g) { g.drawRect(30,30, 300, HT-30); theController.paint(g); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents toggleButton = new java.awt.Button(); setLayout(null); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); toggleButton.setLabel("stop"); toggleButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { toggleButtonActionPerformed(evt); } }); add(toggleButton); toggleButton.setBounds(340, 40, 40, 24); pack(); }//GEN-END:initComponents private void toggleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toggleButtonActionPerformed theController.toggleRunning(); if (theController.getRunning()) toggleButton.setLabel("stop"); else toggleButton.setLabel("go"); }//GEN-LAST:event_toggleButtonActionPerformed /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm System.exit(0); }//GEN-LAST:event_exitForm /** * @param args the command line arguments */ public static void main(String args[]) { BallFrame bf = new BallFrame(); /*java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new BallFrame().setVisible(true); } });*/ } // Variables declaration - do not modify//GEN-BEGIN:variables private java.awt.Button toggleButton; // End of variables declaration//GEN-END:variables }