Results 1 to 4 of 4
  1. #1
    mohsib is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default Problem with applets!!

    I am a newbie to eclipse and java. I wrote a programme but when tried to run it, eclipse compiler generated an error : "Editor does not have an applet. Please help me out!!!

    Java Code:
    import java.io.IOException;
    import javax.swing.JApplet;
    
    
    public class mohsin extends JApplet{
    	public static int a,b,c,o;
    	
    	public void main(String[] args) throws IOException {
    		System.out.println("Enter an operator code to continue:");
    		System.out.println("\n1 for addition.\n2 for subtraction.");
    		System.out.println("\n3 for division.\n4 for multiplication");
    		o = System.in.read();
    		mohsin.option(o);
    	}
    
    public static int addition (int a,int b) {
    	c = a + b;
    	return c;
    }
    
    public static int subtraction (int a,int b) {
    	c = a - b;
    	return c;
    }
    
    public static int division (int a, int b) {
    	c = a / b;
    	return c;
    }
    
    public static int multiplication (int a, int b) {
    	c = a * b;
    	return c;
    }
    
    public static int option (int o) {
    	switch(o)
    	{
    	case 1:
    		mohsin.addition(a, b);
    		break;
    	case 2:
    		mohsin.subtraction(a, b);
    		break;
    	case 3:
    		mohsin.multiplication(a, b);
    		break;
    	case 4:
    		mohsin.division(a, b);
    		break;
    	default:
    		System.err.println("Wrong number entered, try again: ");
    	}
    	return c;
    }
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Problem with applets!!

    If you're trying to run this as an applet, you're doing it all wrong. In fact your code is not GUI code at all, but rather a simple console program.

    First and foremost, decide what you want: a simple console program or an applet GUI. If the latter, then you'll need to read an applet tutorial as it will help you to understand what you need (such as an init method).

  3. #3
    mohsib is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default Re: Problem with applets!!

    I just want to run the programme, whether simple or applet. I was forced to do applet by the compiler because when i clicked run, instead of running, it gives me option to run in either java application or applet. Please tell me how can i run this programme in simple

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,813
    Rep Power
    25

    Default Re: Problem with applets!!

    Remove the "extends JApplet" which will make it a simple console program.

Similar Threads

  1. Help with embed problem with applets
    By Beginner in forum New To Java
    Replies: 0
    Last Post: 10-22-2010, 11:31 AM
  2. Linux java applets: printing problem
    By dixan in forum Java Applets
    Replies: 0
    Last Post: 01-28-2010, 03:52 PM
  3. I need help with Applets
    By ProgrammingPup in forum Advanced Java
    Replies: 1
    Last Post: 12-22-2009, 09:07 PM
  4. problem with applets?
    By srikanthnambu in forum Java Applets
    Replies: 2
    Last Post: 05-22-2009, 07:08 AM
  5. problem with applets..
    By sireesha in forum New To Java
    Replies: 3
    Last Post: 05-21-2009, 04:36 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •