//****************************************************************************** // Cercle.java: Applet // //****************************************************************************** import java.applet.*; import java.awt.*; //============================================================================== // Main Class for applet Cercle // //============================================================================== public class Cercle extends Applet { // PARAMETER SUPPORT: // Parameters allow an HTML author to pass information to the applet; // the HTML author specifies them using the tag within the // tag. The following variables are used to store the values of the // parameters. //-------------------------------------------------------------------------- // Members for applet parameters // = //-------------------------------------------------------------------------- private int m_r = 0; private int m_v = 0; private int m_b = 0; // Parameter names. To change a name of a parameter, you need only make // a single change. Simply modify the value of the parameter string below. //-------------------------------------------------------------------------- private final String PARAM_r = "r"; private final String PARAM_v = "v"; private final String PARAM_b = "b"; // Cercle Class Constructor //-------------------------------------------------------------------------- public Cercle() { // TODO: Add constructor code here } // APPLET INFO SUPPORT: // The getAppletInfo() method returns a string describing the applet's // author, copyright date, or miscellaneous information. //-------------------------------------------------------------------------- public String getAppletInfo() { return "Name: Cercle\r\n" + "Author: _\r\n" ; } // PARAMETER SUPPORT // The getParameterInfo() method returns an array of strings describing // the parameters understood by this applet. // // Cercle Parameter Information: // { "Name", "Type", "Description" }, //-------------------------------------------------------------------------- public String[][] getParameterInfo() { String[][] info = { { PARAM_r, "int", "Parameter description" }, { PARAM_v, "int", "Parameter description" }, { PARAM_b, "int", "Parameter description" }, }; return info; } // The init() method is called by the AWT when an applet is first loaded or // reloaded. Override this method to perform whatever initialization your // applet needs, such as initializing data structures, loading images or // fonts, creating frame windows, setting the layout manager, or adding UI // components. //-------------------------------------------------------------------------- public void init() { // PARAMETER SUPPORT // The following code retrieves the value of each parameter // specified with the tag and stores it in a member // variable. //---------------------------------------------------------------------- String param; // r: Parameter description //---------------------------------------------------------------------- param = getParameter(PARAM_r); if (param != null) m_r = Integer.parseInt(param); // v: Parameter description //---------------------------------------------------------------------- param = getParameter(PARAM_v); if (param != null) m_v = Integer.parseInt(param); // b: Parameter description //---------------------------------------------------------------------- param = getParameter(PARAM_b); if (param != null) m_b = Integer.parseInt(param); // If you use a ResourceWizard-generated "control creator" class to // arrange controls in your applet, you may want to call its // CreateControls() method from within this method. Remove the following // call to resize() before adding the call to CreateControls(); // CreateControls() does its own resizing. //---------------------------------------------------------------------- resize(60, 60); System.out.println("Info:"+getAppletInfo()); // TODO: Place additional initialization code here } // Place additional applet clean up code here. destroy() is called when // when you applet is terminating and being unloaded. //------------------------------------------------------------------------- public void destroy() { // TODO: Place applet cleanup code here } // Cercle Paint Handler //-------------------------------------------------------------------------- public void paint(Graphics g) { // Print trace on Communicator > Java Console System.out.println("paint()"); g.setColor(new Color(m_r, m_v, m_b)); g.fillOval(10, 10, 40, 40); } // The start() method is called when the page containing the applet // first appears on the screen. The AppletWizard's initial implementation // of this method starts execution of the applet's thread. //-------------------------------------------------------------------------- public void start() { // TODO: Place additional applet start code here } // The stop() method is called when the page containing the applet is // no longer on the screen. The AppletWizard's initial implementation of // this method stops execution of the applet's thread. //-------------------------------------------------------------------------- public void stop() { } // TODO: Place additional applet code here public void setCercleColor(int rouge, int vert, int bleu) { m_r = rouge; m_v = vert; m_b = bleu; // Print trace on Communicator > Java Console System.out.println("setCercleColor("+rouge+","+vert+","+bleu+")"); repaint(); } }