//****************************************************************************** // Gm.java: Applet // //****************************************************************************** import java.applet.*; import java.awt.*; import GmFrame; import PictureLabel; //============================================================================== // Main Class for applet Gm // //============================================================================== public class Gm extends Applet { // STANDALONE APPLICATION SUPPORT: // m_fStandAlone will be set to true if applet is run standalone //-------------------------------------------------------------------------- boolean m_fStandAlone = false; private GmFrame fMainFrame; public Button btnShowMainFrame; public Button btnHideMainFrame; public Button btnCreateMainFrame; private Label lbTitle; public PictureLabel lbIcon; private Image icon; // STANDALONE APPLICATION SUPPORT // The main() method acts as the applet's entry point when it is run // as a standalone application. It is ignored if the applet is run from // within an HTML page. //-------------------------------------------------------------------------- public static void main(String args[]) { // Create Toplevel Window to contain applet gm //---------------------------------------------------------------------- Gm applet_gm = new Gm(); GmFrame fMainFrame = new GmFrame("Global Minimum - no method chosen", applet_gm ); // Must show Frame before we size it so insets() will return valid values //---------------------------------------------------------------------- fMainFrame.show(); fMainFrame.hide(); fMainFrame.resize(fMainFrame.insets().left + fMainFrame.insets().right + 500, fMainFrame.insets().top + fMainFrame.insets().bottom + 300); // The following code starts the applet running within the frame window. // It also calls GetParameters() to retrieve parameter values from the // command line, and sets m_fStandAlone to true to prevent init() from // trying to get them from the HTML page. //---------------------------------------------------------------------- fMainFrame.add("Center", applet_gm); applet_gm.m_fStandAlone = true; applet_gm.init(); applet_gm.start(); fMainFrame.show(); } // gm Class Constructor //-------------------------------------------------------------------------- public Gm() { // 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: Gm\r\n" + "Method algorithm author: Jonas Mockus\r\n" + "Converted from C++ to Java: Mindaugas Krapauskas\r\n" + "Created with Microsoft Visual J++ Version 1.0 beta\r\n"+ "Local methods converted from C++ to Java\r\n"+ "and added to 'Gm' by:\r\n"+ "K.Barkauskas, E.Kairys, S.Zukauskas\r\n"+ "Created with Symantec Cafee Java Version 1.0\r\n"; } // 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. //---------------------------------------------------------------------- if (m_fStandAlone == false) { resize(400, 60); lbTitle = new Label("Global Minimum:"); btnShowMainFrame = new Button("Show"); btnHideMainFrame = new Button("Hide"); btnCreateMainFrame = new Button("Restart"); icon = getImage(getCodeBase(),"icon3232.gif"); lbIcon = new PictureLabel(icon); add(lbTitle); add(btnShowMainFrame); add(btnHideMainFrame); add(lbIcon); createMainFrame(); } } private void createMainFrame() { fMainFrame = new GmFrame("Global Minimum - no method chosen", this); } // 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 fMainFrame.dispose(); } // gm Paint Handler //-------------------------------------------------------------------------- public void paint(Graphics g) { } // 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() { } public boolean action( Event evt, Object obj) { if (evt.target instanceof Button) { if (evt.target.equals(btnShowMainFrame)) { fMainFrame.show(); } else if (evt.target.equals(btnHideMainFrame)) { fMainFrame.hide(); } else if (evt.target.equals(btnCreateMainFrame)) { createMainFrame(); fMainFrame.show(); remove(lbIcon); remove(btnCreateMainFrame); add(btnShowMainFrame); add(btnHideMainFrame); add(lbIcon); validate(); } else return false; return true; } return false; } // TODO: Place additional applet code here }