/* * TennisApplet.java * * Created on August 9, 2004, 12:02 PM */ /** * * @author levenick */ import java.awt.*; public class TennisApplet extends java.applet.Applet { Game theGame; Image mariaImage, serenaImage; /** Initializes the applet TennisApplet */ public void init() { initComponents(); setSize(500,800); theGame = new Game(); theGame.setTheTA(theTA); mariaImage = getImage(getCodeBase(), "maria.jpg"); // read from current directory serenaImage = getImage(getCodeBase(), "serena.jpg"); // read from current directory theGame.announceScore(); } public void paint(Graphics g) { g.drawImage(mariaImage, 250, 100, 150,150, this); g.drawImage(serenaImage, 50, 100, 150,200, this); } /** This method is called from within the init() method 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 serverScoredButton = new java.awt.Button(); receiverScoredButton = new java.awt.Button(); theTA = new java.awt.TextArea(); setLayout(null); serverScoredButton.setLabel("point for server"); serverScoredButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { serverScoredButtonActionPerformed(evt); } }); add(serverScoredButton); serverScoredButton.setBounds(10, 20, 180, 30); receiverScoredButton.setLabel("point for receiver"); receiverScoredButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { receiverScoredButtonActionPerformed(evt); } }); add(receiverScoredButton); receiverScoredButton.setBounds(210, 20, 170, 30); add(theTA); theTA.setBounds(20, 370, 360, 230); }//GEN-END:initComponents private void serverScoredButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serverScoredButtonActionPerformed //if (!theGame.gameOver()) theGame.serverScored(); }//GEN-LAST:event_serverScoredButtonActionPerformed private void receiverScoredButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_receiverScoredButtonActionPerformed //if (!theGame.gameOver()) theGame.receiverScored(); }//GEN-LAST:event_receiverScoredButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private java.awt.Button receiverScoredButton; private java.awt.Button serverScoredButton; private java.awt.TextArea theTA; // End of variables declaration//GEN-END:variables }