//****************************************************************************** // feigen.java: Applet // //****************************************************************************** import java.applet.*; import java.awt.*; //============================================================================== // Main Class for applet feigen // //============================================================================== public class feigen extends Applet { private Label m_funclab = new Label("f(x)=k*x(1-x)"); private Label m_xvalue = new Label("x = 0.200"); private Label m_kvalue = new Label("k = 2.000"); private TextField m_xset = new TextField(4); private TextField m_kset = new TextField(4); private Button m_change = new Button("Change"); private Button m_iterate = new Button("Next"); double x=0.2; double k=2; // feigen Class Constructor //-------------------------------------------------------------------------- public feigen() { // 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: feigen\r\n" + "Author: Krishnan Eswaran\r\n" + "Created with Microsoft Visual J++ Version 1.1"; } // 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() { // 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(320, 240); // TODO: Place additional initialization code here add(m_funclab); add(m_xvalue); add(m_xset); add(m_kvalue); add(m_kset); add(m_change); add(m_iterate); m_xset.setText("0.20"); m_kset.setText("2.0"); } // 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 } // feigen Paint Handler //-------------------------------------------------------------------------- public void paint(Graphics g) { //g.drawString("Created with Microsoft Visual J++ Version 1.1", 10, 20); } public boolean action(Event event, Object obj) { Object oTarget = event.target; if (oTarget instanceof Button) { Button buttonTarget = (Button)oTarget; String sButtonString = buttonTarget.getLabel(); if (sButtonString.compareTo("Change") == 0) { String s1 = m_xset.getText(); String s2 = m_kset.getText(); x = (Double.valueOf(s1)).doubleValue(); k = (Double.valueOf(s2)).doubleValue(); m_xvalue.setText("x = " + s1); m_kvalue.setText("k = " + s2); return true; } if (sButtonString.compareTo("Next") == 0) { x = k*x*(1-x); m_xvalue.setText("x = " + String.valueOf(x)); return true; } } return false; } // 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 }