Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


sarthak
error
1 Answer(s)      4 years and a month ago
Posted in : Java Beginners


import java.awt.*;
import java.awt.event.*;
class Sum implements ActionListner
{
Frame f ;
button b ;
Text Feildtf,tf1,tf2;
public Sum()
{
f = newFrame("aaa");

b = newButton("Sum");

b.AddactionListner (this);

tf = new TextFeild ();
tf1 = new TextFeild ();
tf2 = new TextFeild();


f.add(tf);
f.add(tf1);
f.add(tf2);
f.add(b);


f.setLayout(new FlowLayout());
f.setSize(400,400);
f.setVisiable(true);

}
public void actionPerformed (ActionEvent e)
{
String s1 = tf.getText();
String s2 = tf1. getText();

int n1 = integer.passesint(s1);

int n2 = integer.passesint(s2);

int n3 = n1+n2;


tf2.setText(String.valueof(n3));
Float f = Float.valueof(s1);
float f1 = f.Floatvalue();
}
public static void main(String ...s)
{
new Sum();
}
}


Advertisement
View Answers

August 6, 2010 at 11:07 AM


Hi Friend,

We have modified your code.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Sum implements ActionListener
{
Frame f ;
Button b ;
TextField tf,tf1,tf2;
public Sum()
{
f = new Frame("aaa");
b = new Button("Sum");

b.addActionListener(this);

tf = new TextField(20);
tf1 = new TextField(20);
tf2 = new TextField(20);


f.add(tf);
f.add(tf1);
f.add(tf2);
f.add(b);


f.setLayout(new FlowLayout());
f.setSize(200,150);
f.setVisible(true);

}
public void actionPerformed (ActionEvent e){
String s1 = tf.getText();
String s2 = tf1. getText();

int n1 = Integer.parseInt(s1);
int n2 = Integer.parseInt(s2);
int n3 = n1+n2;


tf2.setText(Integer.toString(n3));
}
public static void main(String ...s)
{
new Sum();
}
}

Thanks


Related Tutorials/Questions & Answers:
error
error  while iam compiling iam getting expected error
error
"+it); } } this is my program i am getting an error saying cannot find symbol class string
Advertisements
404 error
404 error  struts application having 404 error while hosting to a online server.it works fine in my local machine but dont work in virtual host.showing 404 error
SEVERE: Error listenerStart - Hibernate
SEVERE: Error listenerStart  what is SEVERE: Error listenerStart
error "HTTP Status 500"
error "HTTP Status 500"  How to solve this error "HTTP Status 500
Error with PrintDocument - Java Beginners
Error with PrintDocument  Error: StudRec.java:526: printComponent(java.awt.Component) in PrintableDocument cannot be applied.... Note: Recompile with -Xlint:unchecked for details. 1 error
error within servlet
error within servlet  List leagueList=(List).context.getAttribute("leagueList"); this is one line in my servlet code. but i have error with this line. The error is.... illegal start of type. Cannot find symbol. Symbol:variable
complier error - Java Beginners
error shows syntax errors like: required : int found : byte Runtime error shows logical errors like: int x=2/0; //this expression causes runtime error Thanks  Hi Friend, Difference: Compile time error shows syntax
Error java.lang.NullPointerException hibernate - Hibernate
Error java.lang.NullPointerException hibernate  hello everybody; I'm developping a web application using Struts 1.1 , Hibernate 3.1 and Mysql , and I've got this message error: Etat HTTP 500
java.lang.null error - MobileApplications
java.lang.null error  sis files are not creating by theme editer error is java.lang.null exception
java runtime error - JDBC
java runtime error  when i m running my program by using jdk1.6.0 then it is giving the error of classunsupported major.minor version 50.0.to remove... version error 49.0.so, please suggest how will i compensate this problem
Binding Error in Spring - Spring
Binding Error in Spring  Error: Neither BindingResult nor plain target object for bean name 'loginBean' available as request attribute I am... What could be the cause of this error? Thanks
JScript error - JSP-Servlet
logins while updating profile it will not show any error. But, in many logins it shows error as unterminated string. I am not able to understand this because this error occurs in some logins only. Other logins did not show
connection error - WebSevices
connection error   while conncting a tool(jet profiler for my sql 1.0 released) with my running application ,it reflects following error: connected,but failed to login,read time out
Tomcat error - JSP-Servlet
the error :-this is non microsoft product please see event log . what might be the reason of such error  HI, Can you paste the error log here.We
error occured in oracle - JDBC
error occured in oracle  hi... this is the error i got in oracle 11g when i am trying to insert image ORA-00984:column not allowedd here for the insert statement like this insert into imgapp('1','xxx','G:\image folder\ultrasound
error in code - JDBC
error in code  hi friends i had one problem when i am running the application of jdbc code it is getting that Exception in thread "main" java.lang.NoSuchMethodError: main plz send me the solution for that error   
Hibernate error - Hibernate
Hibernate error  I had run hibernate first example but it an error appeared. Error is java.lang.NullPointerException.  Hi Friend, Please explain in detail your problem so that we can discuss and solve it. If you
deployment error - XML
getting the following error after i deployed my war file on tomcat.I suspecting my... web.xml entries to support spring and site mesh?? here is the error on my console and my web.xml ......... -------------------------------------- SEVERE: Error
submit error - WebSevices
'); form.country.focus(); } Error: The cmbHire value is null. So tell the correct
struts-tablib error - Struts
struts-tablib error  I have got the following error even after i have included all the jar file of particular struts-version i am using org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class
incompatble type error
); } } } trows incampatble type error
jsp error - JDBC
of that a error is like-----------"java.sql.SQLException: [Microsoft][ODBC Driver Manager... the line is not getting incremented u r getting that error just do this change
output error - JSP-Servlet
output error  /*hi friends, the given below is my servlet program error? How can i solve this problem? */ HTTP Status 500... report message description The server encountered an internal error
error message - Java Beginners
error message  sir, while i m trying to execute my first program(print my name)I get error message like" javac is not recognized as internal or external ...blah..blah..or batch file".even i hav tried setting the path variable
error message - JSP-Servlet
error message  hi, friends after complete my servlet programe i can type http://localhost:8080 on the browser. the servlet program is insert data into dbms. but i have errormessage that is "window can not access the specified
Javascript Loop Error - WebSevices
(); Error: Only if loop will executed, Does not comes to else if part. So tell
Deployment Error - Struts
the following error. Note: Here ?action? is the logical name which we mention
runtime error - Java Beginners
runtime error  I created a sample java source ,compiled it succesfully using command prompt but when i tried to run i got the folowing error " Exception in thread "main" java.lang.UnsupportedClassVersionError" I have set
Servlet Error - JSP-Servlet
. Error showing ==>Admin/FirstServlet is not a servlet Sincerely Prakash
java error - Java Beginners
been obsoleted. To get the details of your error, compile your class with Xlint
java compilation error - Applet
java compilation error  hi friends the following is the awt front design program error, give me the replay E:\ramesh>javac product.java Note: product.java uses or overrides a deprecated API. Note
trap error - Java Beginners
trap error  Hello. Am trying to trap this error that appears when i post blank fields to database. "[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression". what i want is a message cannot post
java error - Java Beginners
. But if I want to run that program the fetches me the following error. For example... uninstalled jdk and NetBeans and reinstalled them, Then too its the same error
Error in Code - Development process
Error in Code  Hi; This is my code to get all d records from View_Service table but am getting error. I just copied this from net.I am doing mini project plz send me code to get records. What action should i mention
Programming Error - JSP-Servlet
(); } } }//End of class m geeting error in this can u please tell me whats the error nd how to solve
Java Error - Java Beginners
ch= reader.read(); ^ 1 error import java.io....); //System.out.println("Enter characters, 'q' to quit."); try
java runtime error - JDBC
java runtime error  when i am running my jdbc program using thin driver this error is coming at runtime: Exception in thread "main..., give me the suggesion yo solve this problem  This kind of error due
Error output - JSP-Servlet
Error output  Can anyone please assist me; The printed output should be: The product is 10. But instead of it I got; The product is undefined. Can anyone trace what went wrong of my code pls
Programming Error - JSP-Servlet
integer.parseInt but its giving error. Please Reply me . Thank you
java runtime error - JDBC
java runtime error  sir when i m running the jsp connectivity program it is giving the error as follows:' java.lang.NullPointerException at jsp_servlet.__resplogin._jspService(__resplogin.java:237
Java Error - Java Beginners
Java Error  Here Error near Read Method import java.util.*; import java.io.*; public class inputdemo { public static void main(String[] args) throws IOException { String bookname,author; float price; System.out.println
jsp error - JSP-Servlet
, The 404 or Not Found error message is an HTTP standard response code indicating
runtime error - Java Beginners
runtime error  sir run time error is coming again in this code also null pointer Exception at for( File f:contents) import java.io.*; public class RecentDocumentsDelete { public static void main(String[] args) { String
Error with KeyListeners - Java Beginners
Error with KeyListeners  Here tf1id is Jtextfield,when I implement following code Gives Error Source Code- tf1id.addKeyListener(new KeyAdapter... { //l13.setVisible(false); tf1.setBackground(Color.white); } } }; Error StudRec.java
Programming error - JDBC
) { out.println("Database Error :"+se.getMessage()); } catch(Exception e) { out.println(e.toString()); } } } Please reply me the error in this program because i... out.println("Not Updated"); } catch(SQLException se) { out.println("Database Error
Error 500: WSWS3142E: Error: Could not find Web services engine. - WebSevices
Error Could not find Web services engine   Hi...: faultNode: faultDetail: {}:return code: 500 Error 500: WSWS3142E: Error: Could not find Web services engine. { http://xml.apache.org/axis
Programming Error - JSP-Servlet
(""); } catch(SQLException se) { out.println("Database Error :"+se.getMessage()); } catch(Exception e) { out.println("General Error :"+e.getMessage... ServletException,IOException {doPost(req,res);} } There is some error
 

 

 

DMCA.com