Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4018444
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:59:01+00:00 2026-05-20T09:59:01+00:00

So this source code comes free from this website. http://math.hws.edu/javamath/basic_applets/SliderGraph.html It seems to be

  • 0

So this source code comes free from this website. http://math.hws.edu/javamath/basic_applets/SliderGraph.html It seems to be somewhat old but I don’t know if that is the issue. I would really like to write my own applet but this is exactly what I need and I am very short on time. The code compiles fine with no errors but comes up Exception in thread main java.lang.NoSuchMethodError: main Why is this happening? Where should I add the main method?

import java.awt.*;
import edu.hws.jcm.data.*;
import edu.hws.jcm.draw.*;
import edu.hws.jcm.awt.*;

public class SliderGraph extends java.applet.Applet {



   private DisplayCanvas canvas;

   public void stop() {
      canvas.releaseResources();
   }

   JCMPanel makeSliderPanel(VariableSlider v) {
         // A small utility routing that makes a JCMPanel that contains
         // a VariableSlider and a DisplayLabel that shows the value
         // of the variable associated with that slider.
      JCMPanel p = new JCMPanel();
      p.add(v, BorderLayout.CENTER);
      p.add( new DisplayLabel(v.getName() + " = #", new Value[] { v } ), BorderLayout.EAST);
      return p;
   }


   public void init() {

      Parser parser = new Parser();
      Variable x = new Variable("x");
      parser.add(x);

        // Create the three VariableSliders.  In this case, the sliders have
        //   names.  There is also a Variable associated with each slider,
        //   which has the same name.  This variable is added to the parser
        //   which is passed as the fourth parameter to the constructor, making
        //   it possible to use "a", "b", and "c" in expressions parsed by the
        //   parser.  Adjusting the value on a slider changes the value of the
        //   associated variable, and therefore changes the value of any
        //   expression that refers to that variable.  The second and third
        //   parameters to the constructor give the minimum and maximum Values
        //   on the slider.  Passing "null,null" uses the defaults, namely
        //   new Constant(-5) and new Constant(5).
      VariableSlider a = new VariableSlider("a",null,null,parser);
      VariableSlider b = new VariableSlider("b",null,null,parser);
      VariableSlider c = new VariableSlider("c",null,null,parser);

      canvas = new DisplayCanvas();
      canvas.setHandleMouseZooms(true);
      canvas.add(new Panner());

      LimitControlPanel limits =
           new LimitControlPanel( LimitControlPanel.SET_LIMITS | LimitControlPanel.RESTORE
                                    | LimitControlPanel.EQUALIZE,  false);
      limits.addCoords(canvas);

      ExpressionInput input = new ExpressionInput("a*x^2 + b*x + c", parser);
      Graph1D graph = new Graph1D(input.getFunction(x));

      ComputeButton button = new ComputeButton("Graph it!");

      canvas.add(new Axes());
      canvas.add(graph);
      canvas.add(new DrawBorder(Color.darkGray, 2));

      JCMPanel main = new JCMPanel();  // Build interface out of JCMPanels!
      main.setInsetGap(3);
      main.add(canvas, BorderLayout.CENTER);
      main.add(limits, BorderLayout.EAST);
      JCMPanel bot = new JCMPanel(5,1);
      main.add(bot, BorderLayout.SOUTH);

      bot.add(new Label("Enter a function f(x), which can use the constants a, b, and c:"));
      JCMPanel inputPanel = new JCMPanel();
      bot.add(inputPanel);
      inputPanel.add(input, BorderLayout.CENTER);
      inputPanel.add(button, BorderLayout.EAST);

      bot.add( makeSliderPanel(a) );  // Create and add the sliders.
      bot.add( makeSliderPanel(b) );
      bot.add( makeSliderPanel(c) );

      Controller controller = main.getController();  // Set up error reporting.
      controller.setErrorReporter(canvas);
      limits.setErrorReporter(canvas);

      main.gatherInputs();  // Set up main panel to respond to changes in input objects.
                            // This works since the interface is built of JCMPanels.  For
                            // the same reason, I don't have to add the objects the the
                            // controller.

      button.setOnUserAction(controller);  // Set controller to respond to button.

      setBackground(Color.lightGray);
      setLayout(new BorderLayout());
      add(main,BorderLayout.CENTER);

   } // end init()

} // end class SliderGraph
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:59:02+00:00Added an answer on May 20, 2026 at 9:59 am

    You are likely encountering this issue because you are trying to run the Applet as an Application. Applets do not contain main methods, Applications do. If you want to run the Applet as an Application, just add a main method that does the following:

    1. Create a window (JFrame) to hold the applet.
    2. Make the window’s close box stop the applet.
    3. Create a new applet object, and add it to the window.
    4. Start the applet by calling init(), then start().
    5. Finalize the layout.
    6. Make the window (with the applet in it) visible.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey! I was looking at this code at http://www.gnu.org/software/m68hc11/examples/primes_8c-source.html I noticed that in some
I have only this in my mxml source code: <?xml version=1.0 encoding=utf-8?> <mx:Canvas xmlns:mx=http://www.adobe.com/2006/mxml
I am trying to create a project whose source code comes from 2 different
I'm working this source code: #include <string> #include <vector> #include <iostream> #include <istream> #include
I'm reading this C++ open source code and I came to a constructor but
I have some C++ source code with templates maybe like this - doxygen runs
Everyone uses source-code control to manage versions (right?) and this provides some level of
I have this long and complex source code that uses a RNG with a
I find this line in the ZenTest source code: result = @test_mappings.find { |file_re,
I have this small code library that I'm considering releasing into Open Source. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.