Comment

ashok
need help,
October 29, 2007 at 4:15 PM

import java.awt.*;
import java.awt.event.*;
import java.applet.*;


public class CalculatorApplet extends Applet implements ActionListener
{
private Button keysArray[];
private Panel keyPad;
private TextField lcdField;
private double result;
private boolean first;
private boolean foundKey;
static boolean clearText;
private int prevOperator;

public void init()
{
lcdField = new TextField(20);
keyPad = new Panel ();
keysArray = new Button[17];
result = 0.0;
prevOperator = 0;
first = true;
clearText = true;

setLayout(new BorderLayout());

lcdField.setEditable(false);

for (int i = 0; i <=9; i++)
keysArray[i] = new Button(String.valueOf(i));
keysArray[10] = new Button("/");
keysArray[11] = new Button("*");
keysArray[12] = new Button("-");
keysArray[13] = new Button("+");
keysArray[14] = new Button("=");
keysArray[15] = new Button(".");
keysArray[16] = new Button("CLR");

keyPad.setLayout(new GridLayout (4,4));

for (int i = 7; i <=10; i++)
keyPad.add(keysArray[i]);

for (int i = 4; i <6; i++)
keyPad.add(keysArray[i]);

keyPad.add(keysArray[11]);

for (int i = 1; i <= 3;i++)
keyPad.add(keysArray[i]);

keyPad.add(keysArray[12]);

keyPad.add(keysArray[0]);

for (int i = 15; i >=13; i--)
keyPad.add(keysArray[i]);

add(lcdField, BorderLayout.NORTH);
add(keyPad, BorderLayout.CENTER);
add(keysArray[16], BorderLayout.EAST);

for(int i = 0; i < keysArray.length; i++)
keysArray[i].addActionListener(this);
}

public void actionPerformed(ActionEvent e)
{
foundKey = false;

for (int i = 0; i < keysArray.length && !foundKey; i++)
if(e.getSource() == keysArray[i])
{
foundKey = true;
switch(i)
{
case 0: case 1: case 2: case 3: case 4:
case 5: case 6: case 7: case 8: case 9:
case 15:
if (clearText)
{
lcdField.setText("");
clearText = false;
}
lcdField.setText(lcdField.getText() +
keysArray[i].getLabel());
break;

case 10:
case 11:
case 12:
case 13:
case 14:
clearText = true;
if (first)
{
if(lcdField.getText().length()==0)
result = 0.0;
else
result = Double.valueOf(lcdField.getText()).doubleValue();

first = false;
prevOperator = i;
}
else
{
switch(prevOperator)
{
case 10:
result /= Double.valueOf(lcdField.getText()).
doubleValue();
break;
case 11:
result *= Double.valueOf(lcdField.getText()).
doubleValue();
break;
case 12:
result -= Double.valueOf(lcdField.getText()).
doubleValue();
break;
case 13:
result += Double.valueOf(lcdField.getText()).
doubleValue();
break;
}
lcdField.setText(Double.toString(result));
if (i==14)
first = true;
else
prevOperator = i;
}
break;

case 16:
clearText = true;
first = true;
lcdField.setText("");
result = 0.0;
prevOperator = 0;
break;
}
}
}
}

whenever i try to run this or other applets
this msg is shown:

Exception in thread "main" java.lang.NoSuchMethodError: main

although there is no error found at the time of compilation.
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Applet Questions

need help to create applet
need help to create applet  Can u help me..?? I get a task ...and i dont know how to make it... So I hope that u can help me... Here is the task... ~Create an Applet using all Layout Manager(use whatever component in each 

Java Beginners

Need Help - Java Beginners
Need Help  Hello Sir, Am a beginner of Java. Also i did course... projects in Java as well as J2EE... Can u help me and guide to do a project.../reference/tutorials/ http://netbeans.org/kb/trails/java-ee.html http 

Java Beginners

need help - Java Beginners
need help  Need help in programming in Java  Simple java program that will show the output within quotes using system.out.println();DISPLAYING OUPUT " * " ," *** " ........I used System.out.print 

Java Beginners

Need help - Java Beginners
Need help   To Write a Java program that asks the users to enter a m * n matrix of integers, m and n being the number of rows and columns...; Hi Friend, Please try the following code. We hope that this code will help 

Java Beginners

need help. - Java Beginners
 

Java Beginners

need help with a program - Java Beginners
Java algorithm - need help with a program  Java algorithm - need help with a program 

Java Beginners

need help with a program - Java Beginners
need help with a program   Part I An algorithm describes how... by the user. The output of the program should be the length and width (entered.... First you would need to make up the "test data". For this algorithm, the test data 

Java Beginners

Need *Help fixing this - Java Beginners
Need *Help fixing this  I need to make this program prompt user... and maybe add retrieve function //need help with this one badly. Thanks guys for all the help. import java.text.*; import javax.swing.*; import java.awt.event. 

Applet Questions

Simple Java applet that need usernam, password and textfield.
Simple Java applet that need usernam, password and textfield.  Hi. Anyone can help me on this matter: I need to create a small application that require user to login by username and password. After login, they should meet 

Java Beginners

java loan calculator applet help
java loan calculator applet help  Hi, I could use some help correcting a code here. I need to write a Java applet program (together with its html... Calulator"); LoanCalculator applet = new LoanCalculator(); frame.add(applet 

Java Beginners

Need to create a java applet
Need to create a java applet   Hi people i need to create a java applet for which there will be 2 buttons to indicate small and big. I need to make a circle. When i click small the circle should be small and when i click big 

Java Beginners

Applet - Java Beginners
Applet  sir, I have just started applet. Now i am going to design my resume using java. Now, if I want to attach my photo, which code will suitable for that?? please help 

Java Beginners

need help on writing a program. - Java Beginners
Writing first Java Program  Hi, I need help to write my first Java... roseIndia to get your query solved. check given link to see the solution of your Java problem.http://www.roseindia.net/java/simple-java-program.shtmlThanks 

Java Beginners

Need help in constructing bubble sort
Need help in constructing bubble sort  using a bubble sort, for each...://www.roseindia.net/java/beginners/arrayexamples/bubblesort.shtml http://www.roseindia.net/java/beginners/arrayexamples/BidirectionalBubbleSort.shtml 

Applet Questions

need a login applet in java
need a login applet in java  i'm java beginner. Can some java master teach me how to write a login applet? combine with my coding import... java.text.*; import java.awt.event.*; public class BoatRental extends Applet implements 

Applet Questions

need a login applet in java
need a login applet in java  i'm java beginner. Can some java master teach me how to write a login applet? combine with my coding import... java.text.*; import java.awt.event.*; public class BoatRental extends Applet implements 

Java Beginners

Sales System.. Need Help!! - Java Beginners
Sales System.. Need Help!!  were going to make a sales system in our... help us.. Thank you very much for your reply in my past questions you are a big help.. Thank you so much. Hope you will help me again thanks!! God Bless and more 

Java Beginners

I need your help - Java Beginners
I need your help  What is the purpose of garbage collection in Java, and when is it used?  Hi check out this url : http://www.artima.com/insidejvm/ed2/gc.html http://java.sun.com/javase/technologies/hotspot 

Java Beginners

Allegrograph with java applet - Java Beginners
Allegrograph with java applet  how to start with java applet when related to semantic. im using allegrograph to do it..pls help 

Applet Questions

java - Applet
java  Hi, I need very urgent code............ please help me......... How to convert text to wave conversion? I need java code............ Regards, Valarmathi 

Java Beginners

( Inheritance,need help in Polymorphism, Overriding) - Java Beginners
( Inheritance,need help in Polymorphism, Overriding)  can any one please help me create this application,thank you Advanced Concepts with Classes( Inheritance, Polymorphism, Overriding) Employees in a company are divided 

Java Beginners

need help creating a lift program - Java Beginners
need help creating a lift program  Classes, Methods, Constructors please i need help to create an elevator program Simulating an Elevator write... for any help rendered 

Java Beginners

I need help in doing this. - Java Beginners
I need help in doing this.  Student DataBase i will need creating a program that will be used to manipulate a student database. This portion..., and the student's GPA.using arrays and objects, need to structure the information 

Java Beginners

I need your help - Java Beginners
I need your help  For this one I need to create delivery class for a delivery service .however, this class should contain (delivery number which... the file name is ApplicationDelivery.java Your program must follow proper Java 

Java Beginners

Applet - Java Beginners
{ // The rest of the applet will be in the next // example...; Hi Friend, Please specify the error so that we can help you. Thanks 

HTML Questions

java applet notpad
java applet notpad  i need Codes Or programe in java applet ; i want add this programe to my site html > please help me our   Learn Java...: Java Applet Tutorials 

Applet Questions

java applets - Applet
java applets  hiiiii... i need ur help in usage of java code for navigation of one applet window to other...?? can you plz respond to me 

Applet Questions

Applet - Applet
------------------------"); g.drawString("Demo of Java Applet Window Event Program"); g.drawString("Java...Applet   Namaste, I want to create a Menu, the menu name is "Display... "shortcut key" and "Version" menu item, the frame should be is open. Plz help me 

Java Beginners

Need Help in Java programming
Need Help in Java programming  Hello. Can someone please help me with writing the following program Java program that gives assignment details such as:assignment number,assignment name,due date,submission date,percentage marks 

JSP Servlet Questions

Need help on JAVA JSP
Need help on JAVA JSP  Hi, I have never worked on java and I have... using JAVA JSP). e.g. Tool does not adjust with the resolution of the screen(need to know how I can adjust it based on the cureen system's screen resolution 

Java Beginners

code need - Java Beginners
code need  hi i want to code doing for this. If i have enter the text file in my java project. example input is 1,2,3,4,5(it is in input text file...)  Hi Friend, Try the following code. We hope this will help you 

Applet Questions

loading Java Applet - Applet
loading Java Applet  Hi, I use the archive tag to download my applet...? In the first step i only need code for the log in, after login the rest. Can I control the loading within the applet? thanks 

Applet Questions

applet problem - Applet
applet problem  How can I create a file in client side by a java applet . Surely it will need a signed applet .But how can a signed applet create a file in the client side 

Java Beginners

java program...need help as soon as possible!!! - Java Beginners
java program...need help as soon as possible!!!  Modify the Lexer (15 points): 1. Use a command line argument for the input file for processing tokens ? do not use simple.x 2. Recognize the new tokens > void float 

Java Beginners

Need help in java programming
Need help in java programming  Hello. Can someone please help me with writig the following programm. Assignment 20% Presentation 10% Mini Test 10% Exam 60% Java program that accepts the following details: student 

Java Beginners

( Inheritance, Polymorphism, Overriding)i need help - Java Beginners
( Inheritance, Polymorphism, Overriding)i need help  Advanced Concepts with Classes( Inheritance, Polymorphism, Overriding) i need help to create this application,than you Employees in a company are divided into the classes 

Java Beginners

applet code - Java Beginners
://www.roseindia.net/java/example/java/applet/ Hope that it will be helpful...applet code  hi friends.. i have to oen one applet, in that applet code should be apper what we have written for the applet... this is my 

Java Beginners

really need help on how to write this program plz some 1 help out. - Java Beginners
really need help on how to write this program plz some 1 help out.  i am confused here on what to write can some 1 help out here i dont quite understand how to code it so can some 1 help out. Part II Write, compile and execute 

Applet Questions

java applet problem - Applet
java applet problem  i was doing a program using java applet. I want... and to exit from the applet respectively.Now i want to display a message when... performed by the user. Please help me to solve this. Thanks.  Hi 

Applet Questions

Applet query - Applet
link: http://www.roseindia.net/java/example/java/applet/ Thanks...Applet query  i want to knw d complete detail of why does applet... process. Instead it runs inside a container. Therefore, they do no need a static 

Java Beginners

hello there i need help
i am a beginner, and aside from that i am really eager to learn java please help me with the codes and please explain to me how it works. i only need to use...hello there i need help  : i need to do a program like 

Applet Questions

applet running but no display - Applet
, it is showing that the "Applet as1 started". Please help me to solve this issue... strDefault = "Hello! Java Applet."; public void paint(Graphics g) { String...applet running but no display  Hai, Thanks for the post. I have 

Java Beginners

need java code - Java Beginners
need java code  i want a program for an algorithm in java which is it has some transactions T1=ABCE T2=CDE T3=DE T4=CDEG T5=BG T6... result . For this algorithm i need a program can any help me 

Java Beginners

java help - Java Beginners
java help  Code a try statement that catches an IOException and an EOFException. If an IOException occurs, print the message ?An I/O error occurred....? to the console. You don?t need to code anything within the try block 

Java Beginners

Java help - Java Beginners
Java help  I need to write an application that uses the circle class. It must read a radius of a circle from the user creates a circle object, and return the object. The program creates a circle object by using the above method 

Java Beginners

seriously need help....
seriously need help....  Write a program that will prompt the user to select an appliance, lookup the energy the appliance uses and for each time... program. Use each of the following Java statements at least once in your program 

Applet Questions

drawing shapes in applet - Applet
drawing shapes in applet  hi, i need a single applet prgm which... java.applet.Applet; public class CubeExample extends Applet { Stroke... Applet { public void paint (Graphics g){ Graphics2D ga = (Graphics2D)g 

Java Beginners

help - Java Beginners
help  hi,i am new to java & i do not have progamming background, i... shows the c:\javatutorial> in the command prompt, is there any setting i need to do or what could be the issue? plz help   hello, First complie ur 

Java Beginners

Java Programming Need Help ASAP
Java Programming Need Help ASAP  You are required to develop..., maths mark, communications mark. You will then need accessor and mutator methods... class that creates an array of Students and handles it. You will need 

Java Beginners

PLZ Need some help JAVA...HELP !!
PLZ Need some help JAVA...HELP !!  Create a class names Purchase Each purchase contains an invoice number, amount of sale and amount of sales tax. Include set methods for the invoice number and sale amount. Within the set 

Java Beginners

SubString help - Java Beginners
SubString help  Hi , I would appreciate if somebody could help me... a substring of 35 zeros '00000000000000000000000000000000000' and they could... substring . If it find 35 zeros i need 10 digits in front of it along with those 

Applet Questions

Applet to database error - Applet
Applet to database error  Hi... I had an application where i need to connect to the database for the values to display in the applet.... Following... Applet implements MouseListener{ boolean rect1Clicked,rect1Clicked1,mouseEntered 

Swing AWT

Applet
Applet  I have a java applet that has a button. On clicking the button it should disappear and another applet should appear. How to write this code???? Also in login applet after successful login it should display admin applet 

General

Applet
; Introduction Applet is java program that can be embedded into HTML pages. Java applets... Disadvantages of Java Applet: Java plug-in is required to run applet Java...: First of all we will know about the applet. An applet is a program written in java 

Java Beginners

Applet
Applet  Draw the class hierarchy of an Applet class. Also explain how to set background and forground colors in java 

Applet Questions

Regarding project - Applet
Regarding project  hi friend , iam doing project in Visual cryptography in Java so i need the Help regarding how to make a share of a original imahe into shares anu 

Java Beginners

help
help  i need help with this code. write a java code for a method named addSevenToKthElement that takes an integer array, and an integer k as its arguments and returns the kth element plus 7. any help would be greatly 

Java Beginners

Java applet
Java applet  I wanted as many clicks are there ,circles should be displayed there. I tried this code but it erases previous circles. plz help. public void mouseClicked(MouseEvent m) { x=m.getX(); y=m.getY 

Java Beginners

Java applet
Java applet  I wanted as many clicks are there ,circles should be displayed there. I tried this code but it erases previous circles. plz help. public void mouseClicked(MouseEvent m) { x=m.getX(); y=m.getY 

Applet Questions

Creating an Applet
an Applet using all Layout Manager, can anyone help me in this regard. I donā??t know how to make and please help me. Thanks.   To answer of your query.../java/applet/firstapplet.shtml Thanks 

Applet Questions

java - Applet
java  How can i develop an expert system using applets? can you help me with some sample source code 

Java Beginners

disable keyboard in java applet
disable keyboard in java applet  How to disable key board of my client in an java applet embedded in a website while the applet is running.? Plz help 

Java Beginners

Java Applet
Java Applet  Hi, I have a query, on every mouse click an oval should be drawn. But in my program I have used repaint() function, therefore...;i<4;i++) g.drawOval(x,y,30,30); } Pls help 

Java Beginners

Java Applet
Java Applet  Hi, I have a query, on every mouse click an oval should be drawn. But in my program I have used repaint() function, therefore...;i<4;i++) g.drawOval(x,y,30,30); } Pls help 

Java Beginners

applet
applet  what is applet in java   An applet is a small program that can be sent along with a Web page to a user. Java applets can perform... the following link: Applet Tutorials 

Java Tips and Examples

The APPLET Tag in Detail
the APPLET tag but can't run Java applets. NAME = appletInstanceName This optional attribute specifies a name for the applet instance. With the help...;    After understanding a simple Java-enabled Web page 

Java Beginners

Applet
Applet  Write a Java applet that drwas a line between 2 points. The co-ordinates of 2 points should be passed as parametrs from html file. The color of the line should be red 

Java-Tutorials

The Java Applet Viewer
; the browser should be Java enabled.To create an applet, we need to define... The Java Applet Viewer       Applet viewer is a command line program to run Java applets 

Applet Questions

Applet Graph
Applet Graph  hai, iam new to java plz help me.. 1..i have a table of information(column names) from database(mysql) 2..i have to select any two... a graph between those columns in a applet plz send me the code thank u 

Java Beginners

need sourcecode - Java Beginners
need sourcecode  Hai, I need program for packetization for videos 

Java Beginners

java application/applet - Java Beginners
java application/applet  In this project, the student has to develop and submit a program for a Java application / applet which contains a set of GUI components as detailed below. 1. The Java applet page/application models 

Java Beginners

Need help writing a console program
Need help writing a console program  I need help cant seems to figure it out! Write a program that consists of three classes. The first class...): This is a test, this is only a test! This test is a test of your Java programming 

Java-Tutorials

Applet - Passing Parameter in Java Applet
Applet - Passing Parameter in Java Applet       Introduction Java applet has the feature... page. Applet will display "Hello! Java Applet"  if no parameter 

Java Beginners

guys,, need help,, in java programing,, arrays
guys,, need help,, in java programing,, arrays  create a program where you will input 10 numbers and arrange it in ascending way using arrays 

Applet Questions

Applet - spell check program - Applet
Applet - spell check program  hi, i am writing a applet program -say ' spelling checking utility ' i need to a read text file and check whether... ALSO ATTACH THE APPLET PROGRAM I HAVE ALREADY DEVELOPED IF PERMITED 

Applet Questions

unable to see the output of applet. - Applet
unable to see the output of applet.  Sir, I was going through the following tutorial http://www.roseindia.net/java/example/java/applet...://www.roseindia.net/java/example/java/applet/FirstApplet.html but the problem 

Java Beginners

This is what i need in this Question - Java Beginners
array. so i need your help to know is it correct or wrong Thank you...This is what i need in this Question  You are to choose between two procedures, both of which compute the mini¬mum value in an array of integers. One 

Java Beginners

what is the need of... - Java Beginners
what is the need of...   what is the need of " return type like void ?   Hi Friend, In java, method always require a return type.The main method is the client code therefore jvm does not expected any return 

Java Beginners

Java, CSS help - Java Beginners
Java, CSS help  I need help about menu and submenu programming? Hi there, I have 6 pages and 6 buttons, i want add submenu to each my main buttons, I have to use below code because I want use this function dynamic 

Java Beginners

Help me please!!! - Java Beginners
Help me please!!!  im badly needing the complete code for this project in java!!! can you please help me???!!! it is about 1-dimensional array in java! it goes something like this. . . "GRADES" Student 1: Student 2 

Java Beginners

pls. help me - Java Beginners
pls. help me  please help me i do need now if its okay... Consider the method headings: void funcOne(int[] alpha, int size) int funcSum(int...[] list = new int[50]; int[] Alist = new int[60]; int num; Write Java 

Java Beginners

Hey Guys really need to learn - Java Beginners
Hey Guys really need to learn  Im a java beginner and i want to know... u will use scanf(%d%d%d, & month, day, year). How can i do this in java? Someone can help me.. Thank you so much.   Hi Friend, There are lot 

Java Beginners

Need help
Need help  Hello... I need some help I have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name.. for example.. i have a method name() which 

Java Beginners

Need help
Need help  Hello... I need some help I have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name.. for example.. i have a method name() which 

Java Beginners

how can i draw a table using applet or swings - Java Beginners
how can i draw a table using applet or swings  Hi RoseIndia, Actually, I was trying for creating a table using applet or swings.......... My task... strings and objects...... Please help me out............ Thanking you 

Java Interview Questions

Need help
Need help  Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another drop.... This name list should get from the database. Please help me. By the way, I'm 

Java Beginners

need code - Java Beginners
need code   i want to take the html coding. if user give a input html file the out is html coding in text file. i want to take html coding only. (view -> source) . how it is possible in java.  Hi Friend, Here we 

Java Beginners

Java Image Browsing Applet
Java Image Browsing Applet  Hi. I want to create an applet which is embedded in html page which display image by browsing the files in the computers hard disk... Please help me out 

Applet Questions

applet - Applet
in Java Applet.",40,20); } } 2) Call this applet with html code...: http://www.roseindia.net/java/example/java/applet/ Thanks....  Hi Friend, Try the following code: 1)Create an applet 

Java Beginners

need program - Java Beginners
need program  I need a java program to get the multiple student name and mark.display the student information by sorting the marks in ascending or desending order.  Hi Friend, Try the following code: import 

Applet Questions

Java Applet - Adding a Button to Decrease a Total
Java Applet - Adding a Button to Decrease a Total  Hello everyone... for your help!   Here is an applet program that will increment... java.applet.*; public class Final extends Applet implements ActionListener 

Java Beginners

Java Question Anyone need some HELP !!
Java Question Anyone need some HELP !!  Create a file that contains... of the two files. Note: For the above code, you need POI api. import... and poi-scratchpad-3.2-FINAL-20081019.jar files into the following path: \Java 

Applet Questions

Applet - Applet
, Applet Applet is java program that can be embedded into HTML pages. Java applets... in details to visit.... http://www.roseindia.net/java/example/java/applet...Applet  what is the concept of applet? what is different between 

Java Beginners

Need help with this!
Need help with this!  Can anyone please help me... to a file at all at this time. Any help would be greatly appreciated, thank you... to effectivly end the loop with out the need to break it. for(i=(0); i < 

Applet Questions

Creating a log in a text file - Applet
Creating a log in a text file  Hey there, I have created an applet that supports 4 different languages, and the applet needs to be runnable as an application. Therefore i have added it onto a frame. I need to create a text file 

Applet Questions

Swing - Applet
Swing  Hello, I am creating a swing gui applet, which is trying... to exaplain. Can you please help me?  Hi friend, import... information on swing visit to : http://www.roseindia.net/java/example/java 

Swing AWT

Need Help with Java-SWING progrmming - Swing AWT
Need Help with Java-SWING progrmming  Hi sir, I am a beginner in java-swing programming. I want to know how we can use the print option with a program in swing. Could you help me with an example? Regards Sreejith  

Java Beginners

need help pleaseee....i weak in java
need help pleaseee....i weak in java  QUESTION 1 You are required to write an application called Customer Billing System. This system... meter reading, current meter reading and charges. Write a structured Java program 

Java Beginners

need help with java program as soon as possible
need help with java program as soon as possible  So my assignment is to write a program that used while loops to perform 6 different things. 1. prompt the users to input two integers: firstNum and secondNum (firstNum must be less 

Java Interview Questions

i need your help - Java Interview Questions
i need your help  Write a java program that: i. Allows user to enter 2 numbers from the keyboard ii. Uses a method to compare the two numbers to determine which is larger iii. Print to the screen stating which number is larger 

Advertisements Advertisements
 

 

 

DMCA.com