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



Home Answers Viewqa Java-Beginners Not getting desired output while button is pressed in java applet program
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Tushar Agrawal
Not getting desired output while button is pressed in java applet program
0 Answer(s)      2 years and 5 months ago
Posted in : Java Beginners


//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>

Advertisement
View Answers

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
error while running the applet - Java Beginners
prompt. You will be got definitily your output in a applet viewer. Thanks...error while running the applet  import java.applet.Applet; import...=0; public void init() { Button b1 = new Button("create window
Advertisements
Java Program - Applet
Java Program  A java program to move a text in applet from right to left.  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/applet/SampleBanner.shtml Thanks
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
Hide Close Button in Java Applet - Java Server Faces Questions
Hide Close Button in Java Applet  I have an applet while running...... button or close button. Java Applet Code - Show and Hide Buttons on Applet  Java Applet code to display minimize and maximize button on Applet and code
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
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
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
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 program - Applet
Java program  Can you please provide me a code for scientific calculator in java I need that in urgent.Please post me the answers  Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial/java
Java Program - Applet
Java Program  How to Draw various types of Charts Like pie,Line,Bar... the following links: http://www.roseindia.net/java/example/java/swing/draw-simple-bar-chart.shtml http://www.roseindia.net/java/example/java/swing/draw-pie
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
plz explain me the output of program - Java Beginners
plz explain me the output of program  Hi friends, can u please explain me the output of below program with proper explanation of each and every line...;Hi Friend, Output of this program is: a=2 b=0 c=0 mul=27 volume=18
applet program code - Applet
applet program code  hello sir, i did't get the code for below problem... please help me... 1.An applet program to draw a line graph for y=2x+5.[for suitable values of x & y
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
java applet problem - Applet
java applet problem  i was doing a program using java applet. I want... i hv entered four nos in the textboxes and i pressed the Add button... for add,multiply,divide,minus and a clear and exit button to clear the textboxes
applet program
applet program  applet to simulates a traffic signal light with short delay between states
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
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
While loop break causing unwanted output
While loop break causing unwanted output  Below I will paste my code... it will output that I was correct but after that it will output something that I'm... as I'm just beginning learning java. import java.util.Scanner; public class
Applet program for drawing picture and graph - Applet
Applet program for drawing picture and graph  Please send me the program(code) of drawing picture and graph in Applet.  Hi Friend.../applet/ http://www.roseindia.net/tutorial/java/swing/createHumanFace.html Hope
core java - Applet
core java  how can draw rectangle in applet. when i pressed in mouse button the rectangle's size will also increase
Applet - spell check program - Applet
Applet - spell check program  hi, i am writing a applet program -say... ALSO ATTACH THE APPLET PROGRAM I HAVE ALREADY DEVELOPED IF PERMITED . KINDLY HELP The program does match the input text against a DICTIONARY
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
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
sample Applet program
sample Applet program  I need Source Code for sample Applet program.   Hi Friend, Please visit the following link: Applet Tutorials Thanks
getting classnotfound exception while running login application
getting classnotfound exception while running login application  hi, I am getting Error creating bean with name 'urlMapping' defined... to bean 'loginController' while setting bean property 'urlMap' with key
The Java Applet Viewer
The Java Applet Viewer       Applet viewer is a command line program to run Java applets...) of the browser executes that code and displays the output.. So for running the applet
An Applet program for Drawing picture & graph - Applet
An Applet program for Drawing picture & graph  How can I write an Applet program for drawing picture and graph having various colours and tools provided
 

 

 

DMCA.com