Not getting desired output while button is pressed in java applet program

Ads
 

Not getting desired output while button is pressed in java applet program

//The code is as follows,i want that whatever data is there in text field T1 and T2 get subtracted and comes in T3 after we press the button...///

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import  java.applet.*;
import java.awt.Font;
public class abc extends Applet implements ActionListener
{
TextField T1,T2,T3,T4,T5;
Button B1;
String ST1,ST2,ST3;
double a;
public void paint(Graphics g)
{

setLayout(null);
setBackground(Color.pink);
g.drawRect(0,0,600,500);
g.drawLine(0,50,600,50);
g.drawLine(0,80,600,80);
g.drawLine(150,50,150,80);
g.drawLine(300,50,300,80);
g.drawLine(0,110,600,110);
g.drawLine(120,80,120,150);
g.drawLine(240,80,240,150);
g.drawLine(360,80,360,150);
g.drawLine(480,80,480,150);
g.drawLine(0,150,600,150);
g.drawLine(230,150,230,360);
g.drawLine(300,150,300,170);
g.drawLine(370,150,370,170);
g.drawLine(460,150,460,390);
g.drawLine(230,170,460,170);
g.drawLine(0,390,600,390);
g.drawLine(0,360,460,360);
g.drawLine(345,200,345,390);
g.drawLine(0,200,345,200);
g.drawLine(0,420,600,420);
g.drawLine(0,220,230,220);
g.drawLine(0,240,230,240);
g.drawLine(0,260,230,260);
g.drawLine(0,280,230,280);
g.drawLine(0,300,230,300);
g.drawLine(0,320,230,320);
g.drawLine(0,340,230,340);
g.drawLine(140,220,140,360);

Label L1=new Label("A COMPANY PVT.LTD.");
L1.setBounds(150,5,440,30);
Font myFont = new Font("TimesRoman", Font.BOLD, 18);
L1.setFont(myFont);
Label L2=new Label("Ph. :01222");
L2.setBounds(200,30,250,20);
Label L3=new Label("Date ___/___/_____");
L3.setBounds(470,30,120,20);

Label L4=new Label("Vehicle No.");
Label L5=new Label("Colliery");
Label L6=new Label("Unloaded at:");
L4.setBounds(5,55,120,10);
L5.setBounds(155,55,130,15);
L6.setBounds(315,55,120,10);

this.add(L1);
this.add(L2);
this.add(L3);
this.add(L4);
this.add(L5);
this.add(L6);

Label L7=new Label("Desp.Wt.in MT");
L7.setBounds(10,84,100,25);
this.add(L7);
Label L8=new Label("Recd.Wt.in MT");
L8.setBounds(135,84,100,25);
this.add(L8);
Label L9=new Label("Shortage in MT");
L9.setBounds(255,84,100,25);
this.add(L9);
Label L10=new Label("Freight Rate PMT");
L10.setBounds(375,84,100,25);
this.add(L10);
Label L11=new Label("Advance Rs.");
L11.setBounds(500,84,95,25);
this.add(L11);

Font myFont1 = new Font("TimesRoman", Font.BOLD, 10);
Label L12=new Label("Weight  X");
L12.setBounds(240,152,55,15);
this.add(L12);
L12.setFont(myFont1);
Label L13=new Label("Freight  =");
L13.setBounds(310,152,55,15);
    this.add(L13);
L13.setFont(myFont1);
Label L14=new Label("Amount");
L14.setBounds(390,152,55,15);
this.add(L14);
L14.setFont(myFont1);


Font myFont2 = new Font("ArialBlack", Font.BOLD, 10);
Label S1=new Label("Particulars");
S1.setBounds(15,221,30,18);
S1.setFont(myFont2);
this.add(S1);
Label S2=new Label("Shortage");
S2.setBounds(5,241,30,18);
S2.setFont(myFont2);
this.add(S2);
Label S3=new Label("Advance");
S3.setBounds(5,261,30,18);
S3.setFont(myFont2);
this.add(S3);
Label S4=new Label("Commission");
S4.setBounds(5,281,30,18);
S4.setFont(myFont2);
this.add(S4);
Label S5=new Label("Munsiana");
S5.setBounds(5,301,30,18);
S5.setFont(myFont2);
this.add(S5);
Label S6=new Label("Other Deduction");
S6.setBounds(5,321,30,18);
S6.setFont(myFont2);
this.add(S6);
Label S7=new Label("Total");
S7.setBounds(5,341,30,18);
S7.setFont(myFont2);
this.add(S7);
Label R1=new Label("Amount");
R1.setBounds(150,221,40,18);
R1.setFont(myFont2);
this.add(R1);
TextField R2=new TextField();
R2.setBounds(145,241,80,18);
R2.setFont(myFont2);
this.add(R2);
TextField R3=new TextField();
R3.setBounds(145,261,80,18);
R3.setFont(myFont2);
this.add(R3);
TextField R4=new TextField();
R4.setBounds(145,281,80,18);
R4.setFont(myFont2);
this.add(R4);
TextField R5=new TextField();
R5.setBounds(145,301,80,18);
R5.setFont(myFont2);
this.add(R5);
TextField R6=new TextField();
R6.setBounds(145,321,80,18);
R6.setFont(myFont2);
this.add(R6);
TextField R7=new TextField();
R7.setBounds(145,341,80,18);
R7.setFont(myFont2);
this.add(R7);

Label L15=new Label("Total Freight Payable Rs.");
L15.setBounds(190,366,150,19);
this.add(L15);
Label L16=new Label("Rupees....................................................................................");
L16.setBounds(30,395,200,19);
this.add(L16);
Label L17=new Label("Paid Date.................................................");
L17.setBounds(10,425,200,19);
this.add(L17);
L17=new Label("Recieved By Name....................................");
L17.setBounds(10,450,200,19);
this.add(L17);
Label L18=new Label("Mobile No........................................");
L18.setBounds(10,475,200,19);
this.add(L18);
Label L19=new Label("Signature");
L19.setBounds(250,475,150,19);
this.add(L19);
Label L20=new Label("For:A Co.(P)Ltd");
L20.setBounds(440,475,155,19);
this.add(L20);

T1=new TextField();
T1.setBounds(5,118,110,28);
this.add(T1);
T2=new TextField();
T2.setBounds(125,118,110,28);
this.add(T2);
T3=new TextField();
T3.setBounds(245,118,110,28);
this.add(T3);
T4=new TextField();
T4.setBounds(365,118,110,28);
this.add(T4);
T5=new TextField();
T5.setBounds(485,118,110,28);
this.add(T5);

B1=new Button("Submit");
B1.setBounds(200,520,100,23);

B1.addActionListener(this);
this.add(B1);

T1.setText("40");
T2.setText("20");
ST1=T1.getText();
ST2=T2.getText();
a=Double.parseDouble(ST1)-Double.parseDouble(ST2);
ST3=""+a;
}

public void actionPerformed(ActionEvent ev){
Object obj=ev.getSource();
if(obj==B1)
{

System.out.println("wjnqjqw");
}
else
{
T3.setText(ST3);
System.out.println("assassas");

}
}   
}//<applet code="abc.java" width=600 height=550></applet>
View Answers

Ads









Related Tutorials/Questions & Answers:
Not getting desired output while button is pressed in java applet program
Not getting desired output while button is pressed in java applet program ... T1 and T2 get subtracted and comes in T3 after we press the button.../// import...*; import java.awt.Font; public class abc extends Applet implements ActionListener
while executing a java program
while executing a java program  while iam executing a simple java program after i type "java simple.java" there was a an error occuring.the error is "exception in thread "main" java.lang.noclassdeffounderror:simple" what thus
Advertisements
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
Write an applet program to transfer the content of the text field into the component on clicking a button
Write an applet program to transfer the content of the text field into the component on clicking a button  Write an applet program to transfer the content of the text field into the component on clicking a button
Nested Ajax--not getting output
in my jsp pages . on button click,It gives me my desired answer. Same,in next...Nested Ajax--not getting output  Hi everyone... I have two.jsp page......it shows me contents of two.jsp.....but onClick of button, it does not gives me
java applet - Applet
java applet  I want to close applet window which is open by another button of applet program. plz tell me!   Hi Friend, Try...://www.roseindia.net/java/example/java/applet/ Thanks
Applet program
Applet program  Write a java applet for the following case- The hotel Maharaja provides the facility to its customers to select any one room (from.... 100. All above charges are applicable per day basis. The applet will display
applet program
applet program  applet to simulates a traffic signal light with short delay between states
Write an applet that prints "Lear Java it is useful" at the current cursor position whenever the mouse left button is clicked.
Write an applet that prints "Lear Java it is useful" at the current cursor position whenever the mouse left button is clicked.   Write an applet that prints "Lear Java it is useful" at the current cursor position whenever
output of the program
output of the program  public static int sum(List list) { int sum = 0; for ( Iterator iter = list.iterator(); iter.hasNext(); ) { int i = ((Integer)iter.next()).intValue(); sum += i; } return sum
The Java Applet Viewer
The Java Applet Viewer       Applet viewer is a command line program to run Java applets... that code and displays the output.. So for running the applet,  the browser
The Java Applet Viewer
The Java Applet Viewer       Applet viewer is a command line program to run Java applets... that code and displays the output.. So for running the applet,  the browser
The Java Applet Viewer
the output.. So for running the applet,  the browser should be Java enabled... The Java Applet Viewer      ... is a command line program to run Java applets. It is included in the SDK. It helps you
Java Applet
Java Applet   How to add Image in Java Applet? what is getDocumentBase
The Java Applet Viewer
The Java Applet Viewer       Applet viewer is a command line program to run Java applets... the location of the applet program and the Options argument specifies how to run the Java
sample Applet program
sample Applet program  I need Source Code for sample Applet program.   Hi Friend, Please visit the following link: Applet Tutorials Thanks
About running the Applet Program
About running the Applet Program  Hi I have composed an Applet Program and compiled the program, until that it is fine but how to run the Applet program(compiling i typed as javac AppletDemo.java)? Is compiling
About running the Applet Program
About running the Applet Program  Hi I have composed an Applet Program and compiled the program, until that it is fine but how to run the Applet program(compiling i typed as javac AppletDemo.java)? Is compiling
How to create the program in Java for getting the forgotten Password Form?
How to create the program in Java for getting the forgotten Password Form?  Hi, Our enterprise application requires the development of a form... to the user on email address. How to create the program in Java for getting
java applet
java applet  Creation of Applet for Personal Details Form When.... The applet must include the following validations: ? The FirstName, Address1... format, and should be later than the current date. Create an OK button
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 Applet - Creating First Applet Example
the applet. An applet is a program written in java programming language... an applet program. Java source of applet is then compiled into java class file and we... Java Applet - Creating First Applet Example   
java applet
java applet  why java applet programs doesn't contain main method
java applet
java applet  why java applet programs doesn't contain main method
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
program to create student report using java applet,read the input using text boxesand generate the grades..?
program to create student report using java applet,read the input using text boxesand generate the grades..?   sir plz give me java applet codes for above question
java applet
java applet  If i insert in database from applet this work, but from applet.html don't
Java Applet
Java Applet  Hi, What is Java Applet and how it can be useful in development of Java programs? Can anyone tell me the url to learn Java Applet? Thanks   Hi, See the tutorial at: Applications and Applets Thanks
java applet
java applet   I want code to implement (1) user will enter how many nodes (2)it should allow that no. of clicks and circle should be displayed at that position
Play Audio in Java Applet
Play Audio in Java Applet       Introduction Java has the feature of the playing the sound file. This program will show you how to play a audio clip in your java applet
Applet : Java Glossary
Applet : Java Glossary       An applet in java programming language is a small program that only runs.... Activation of an applet results in execution of a program. Applet also provides

Ads