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

 
 


Tushar Agrawal
Not getting desired output while button is pressed in java applet program
0 Answer(s)      10 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>
View Answers









Related Pages:
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
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
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
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
output
output  Sir,I am experiencing some problems with the output of this program.I got some useful help this website,but the output of the program isn't producing what it should.let me explain the output below is what happen when
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 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
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
Swing - Applet
Swing  Hello, I am creating a swing gui applet, which is trying to output all the numbers between a given number and add them up. For example... showing the result, and thee will be a button hihc the user will click
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
I/O Program output error
I/O Program output error  Hello All, I am working on a program that requries me to read and analyze a .txt file and output the results to a .txt file, but I am getting incorrect output. I have been successfull with part
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class...; while ((c = in.read()) != -1) { out.write(c); } out.close
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class...; while ((c = in.read()) != -1) { out.write(c); } out.close
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
; Introduction Applet is java program that can be embedded into HTML pages. Java applets...: First of all we will know about the applet. An applet is a program written in java... you will see, how to write an applet program. Java source of applet
input output
; Introduction The Java I/O means Java Input/Output and is a part... you will learn how to write java program to read file line by line. We will use... DataInputStream with an appropriate BufferedReader. Here is the code of java program
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
scrollbar - applet - Applet
for more information. http://www.roseindia.net/java/example/java/applet/ Thanks...scrollbar - applet  Hi!! It is the program for a vertical scroll bar and the output is (small vertical scrollbar). Suppose if I want a lengthy
applet not initalized - Applet
applet not initalized  I HAVE TRIED MY HEART OUT BUT THIS APPLET IS NOT GETTING INITIALIZED ..... THE FOLLOWING IS THE PROGRAM I HAVE WRITTEN...*; /* */ public class card extends Applet implements ActionListener,ItemListener
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
Jav Applets - Applet
Jav Applets  I need to write a small payroll program, using applet... rate, and a non-editable text field for the output. It should also also provide labels to identify all three text fields and a button to calculate the result
applet - Applet
*; import java.awt.*; public class CreateTextBox extends Applet implements...); add(text,"center"); Button button = new Button("Hello"); button.addActionListener(this); add(l); add(text); add(button
Java Application change to java applet
Java Application change to java applet   Hi every Java Masters i'm Java beginner ,and i want below this figures source code convert to Java Applet... extends Applet implements ActionListener{ TextField text,output; Label
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
core java - Applet
core java  Hellow sir, how can canvert number to words. Output like...]In Words 1 to Crore upto chandge the number i am trying to create a program when i... String convert(int number){ int n=1; int word ; string=""; while ( number != 0
input output in java
input output in java  java program using filereader and filewriter...; while ((c = in.read()) != -1) { out.write(c); } out.close...("C:/new.txt"); int c; while ((c = in.read()) != -1){ out.write(c
How to get the output of jsp program using Bean
How to get the output of jsp program using Bean  Hello my Roseindia netizen has suggested one program but when i implement the same i am not getting the ouput.i want the output of the program .i posted the same program below so
getting radio button at start of each row of table - Struts
getting radio button at start of each row of table  i have done the following things, and this is fine for me. But i want radio button at the place... rupesh java sachin vc++ amit java monty php i want radio button
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
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
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
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
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 - 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... java.awt.event.*; public class menu2frame extends Applet implements WindowListener
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
program that uses while loops to perform the following steps :
program that uses while loops to perform the following steps :  Write a program that uses while loops to perform the following steps : a. Prompt... inclusive f. Output all the uppercase letters. (java coding: pls help me
Using Applet in JSP
to include Applet in JSP page What is applet ? Applet is java program that can...://www.roseindia.net/java/example/java/applet/ JSP-Applet To use applet in JSP page we can use..., width of applet or bean display jreversion: version of Java Runtime
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
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
Adding a Rollover and Pressed Icon to a JButton Component in Java
Adding a Rollover and Pressed Icon to a JButton Component in Java... in java. Rollover means moving mouse pointer above the icon on the button.  This program shows an icon or image on the button if the mouse pointer moves
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
select date in desired format
select date in desired format  how to select date from the database in DD/MM/YYYY format, because if i am trying select data from the database i am getting value in yyyy/mm/dd and time format like below "2012-05-07 00:00:00.0
Swing Applet Example in java
Java - Swing Applet Example in java   ... swing in an applet. In this example, you will see that how resources of swing are used in the applet. All objects except lbl, have been used from Applet class
getting error while inserting values in database
getting error while inserting values in database  AddUser.java...(); Context envContext = (Context) initContext.lookup("java:/comp/env...) { out.println("An Error Had occurred while accessing the database
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
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
error while compiling - Java Beginners
error while compiling  i am facing problem with compiling and running a simple java program, can any one help me, the error i am getting is javac is not recognised as internal or external command  Check if you JAVA_HOME
Redirecting the console output into a file in Java
Redirecting the console output into a file in Java  Hi, i coded a program that read specific lines from a text file. It's working well. Now i want to redirect the output of the console to a text file. i used your tutorial

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.