Register FAQ Calendar Search Today's Posts Mark Forums Read

Go Back   Java Programming Forums > Java Programming > New to Java

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 16-08-2008, 04:42 AM
Junior Member
 
Join Date: Aug 2008
Posts: 7
AnithaBabu1 is on a distinguished road
Smile Calculator-applet

Hi all,my assignment is that i have to enter two numbers in two different text fields n thereby,i have to get the result(add/sub/mul/div) in the third text field.Initially i have done with addition of two numbers,but i didn't get the o/p.Will u plz tell me whatz the problem!Thank u!!!!

Java Code:
import java.awt.*;
import java.applet.*;

public class GUI3 extends Applet {
        TextField xField;
        TextField yField;
        TextField answer;
        Button    eqButton;
        Label     plusLabel;

	void eqButton_Clicked(Event event) {
                         // do this when the eqButton clicked,
          int x=0,y=0; 
     
          // get the value of xField
          String xS= xField.getText();
          try{   x= Integer.parseInt(xS);} 
          catch( NumberFormatException e) 
             { answer.setText("wrong number format!");}

          // get the value of yField
          String yS= yField.getText();
          try{   y= Integer.parseInt(yS);} 
          catch( NumberFormatException e) 
             { answer.setText("wrong number format!");}

          // do the addition and display its result
          int ans=x+y;
          answer.setText(""+ans);
          repaint();
	}

	public void init() {

                // Layouting the gui parts.

		setLayout(null);  // Parts layout follows the geometric
                                  // parameters of reshape.

                xField = new TextField();
                xField.reshape(20,20,60,30);
                add(xField);

                yField = new TextField();
                yField.reshape(110,20,60,30);
                add(yField);
                
                answer = new TextField();
                answer.reshape(220,20,60,30);
                add(answer);
                
                eqButton = new Button("=");
                eqButton.reshape(180,20,30,30);
                add(eqButton);

                plusLabel = new Label("+");
                plusLabel.reshape(90,20,20,30);
                add(plusLabel);

	}

	public void actionPerformed(ActionEvent event) {
		if (event.getSource() == eqButton)
                         {
			 eqButton_Clicked(event);
			
		}
		
	}

}
/*<Applet code=GUI3.class width=400 height=400></Applet>*/
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Custom Search
100 most searched terms
Search Cloud
"bad endpoint type" com.sun.xml.internal.messaging.saaj.soapexceptionimpl com.sun.xml.internal.messaging.saaj.soapexceptionimpl: bad endpoint type com.sun.xml.internal.messaging.saaj.soapexceptionimpl: java.security.privilegedactionexception com.sun.xml.internal.messaging.saaj.soapexceptionimpl: java.security.privilegedactionexception: com.sun.xml.internal.messaging.saaj.soapexceptionimpl: java.security.privilegedactionexception: com.sun.xml.internal.messaging.saaj.soapexceptionimpl: message send failed com.sun.xml.internal.messaging.saaj.soapexceptionimpl: message send failed com.sun.xml.messaging.saaj.soapexceptionimpl: java.security.privilegedactionexception com.sun.xml.messaging.saaj.soapexceptionimpl: java.security.privilegedactionexception: com.sun.xml.messaging.saaj.soapexceptionimpl: message send failed convert arraylist to map date_format_now eclipse shortcut keys ejb3 quartz java convert double to binary java forum java forums java jtextarea bold java jtextarea color java jtextarea font java jtextarea font size java programmer forum java programmers forum java programming forum java programming forums java read last line java read last line of file java sendkeys java.security.privilegedactionexception java.security.privilegedactionexception: com.sun.xml.internal.messaging.saaj.soapexceptionimpl java.security.privilegedactionexception: com.sun.xml.internal.messaging.saaj.soapexceptionimpl: bad response java.security.privilegedactionexception: com.sun.xml.internal.messaging.saaj.soapexceptionimpl: message send failed java.security.privilegedactionexception: com.sun.xml.messaging.saaj.soapexceptionimpl: message send failed javapf javaprogrammingforums jtextarea bold jtextarea font jtextarea font color jtextarea font size programing forums programming forums reset jcombobox saaj0008 saaj0008: bad response; bad request saaj0008: bad response; not found severe: saaj0008 severe: saaj0008: bad response; bad request severe: saaj0008: bad response; not found soap java.security.privilegedactionexception soapexceptionimpl: bad endpoint type textpad java

All times are GMT. The time now is 11:42 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.