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



Home Answers Viewqa Applet Jav Applets
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


ricky
Jav Applets
1 Answer(s)      4 years and 6 months ago
Posted in : Applet


I need to write a small payroll program, using applet, that provides a text field for the number of hours, a text field for the pay 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.

Thanks

Advertisement
View Answers

April 6, 2010 at 3:31 PM


Hi Friend,

Try the following code:

1)
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class OpenWindow extends Applet implements ActionListener {
Label l1,l2,l3;
TextField t1,t2,t3;
Button b;
Panel p;

public void init(){
l1=new Label("Number of hours");
l2=new Label("Pay Rate");
l3=new Label("Total");
t1=new TextField(20);
t2=new TextField(20);
t3=new TextField(20);

p=new Panel(new GridLayout(4,2));
t3.setEditable(false);
b = new Button("Calculate");
b.addActionListener(this);
p.add(l1);
p.add(t1);
p.add(l2);
p.add(t2);
p.add(l3);
p.add(t3);
p.add(b);
add(p);
}
public void actionPerformed(ActionEvent e){
int hours=Integer.parseInt(t1.getText());
int rate=Integer.parseInt(t2.getText());
int total=hours*rate;
t3.setText(Integer.toString(total));
}
}

2)applet.html:

<html>
<body>
<h1>Java Applet Demo</h1>
<applet code=OpenWindow .class width=500 height=400>
</applet>
</body>
</html>

Thanks




Related Tutorials/Questions & Answers:
Jav Applets - Applet
Jav Applets  I need to write a small payroll program, using applet, that provides a text field for the number of hours, a text field for the pay rate, and a non-editable text field for the output. It should also also provide
Applets?
Applets?  applets are using now a days   Please visit the following link: Applet Tutorials
Advertisements
jav-util.zip
jav-util.zip  i need to load a zipfile in to my class while executing and i have extract each file in that zip and a particular file content i need to desplay how can i do this please help me
jav
JAv method overloading
JAv method overloading  What restrictions are placed on method overloading
jav compolation error - Java Beginners
jav compolation error  find symbol error
jav beginners - Java Beginners
jav beginners  pl. let me know the logic and the program to print the prime and twin prim numbers thanks  Hi Friend, Try the following code: class TwinPrimes{ public static void main (String
APPLETS - Security
APPLETS  In java applets sun.misc is not working can any body help me for the alternate solution. while using new sun.misc.BASE64Encoder().encode(enc); i got runtime error... java.security.AccessControlException
jav a - Design concepts & design patterns
jav a  Q.1. Write a program in Java to perform the addition of two complex numbers.   Hi Friend, Try the following code: public class ComplexNumber{ private int a; private int b; public ComplexNumber
Applications and Applets
Applications and Applets       Now a days, Java is widely used for applications and applets. The code... the user's browser. Applets can be very useful, user friendly programs or can
Applications and Applets
Applications and Applets       Now a days, Java is widely used for applications and applets. The code... the user's browser. Applets can be very useful, user friendly programs or can
Servlet v/s Applets - Servlet Interview Questions
Servlet v/s Applets  what is difference between servlets & applets
Programming using applets and oracle - Applet
Programming using applets and oracle  Develop an Online Examination software in java using applets as front end and oracle as back end. Software should handle at least ten users at a time. There are Multiple Choice questions
Applets in Java
Applet is a Java program embedded within HTML pages. Java applets is compatible with almost all the web browsers like Mozilla Firefox, Google Chrome, Internet explorer, Netscape navigator and others that are java enabled. Applets
Free Java Applets
Free Java Applets       There are many free java applets available on the web that you can use in your website. These applets includes menu, clock, slide show, image animation
Should we go for javascript or applets for online exam project using java
Should we go for javascript or applets for online exam project using java  Hi, I am new to java and i am working on online examination project.As soon as the candidate login successfully a window pop up should appear
Role of Java Applets in Web Application Development
In this article, we are discussing about the role of Java Applets in web application development. As we all know that an Applet is a simple Java program, which is written in Java programming language that extends the java.applet.
I am new to java applets. When i run this code on applet viewer status is displayed that applet not initialized
I am new to java applets. When i run this code on applet viewer status is displayed that applet not initialized  import java.awt.*; import java.awt.event.*; import java.applet.*; public class Textfields extends Applet implements
What is Applet in Java?
computer. Applets are used to make the web site more dynamic and entertaining. The main difference between Java based applications and applets...? Applets are cross platform and can run on Windows, Mac OS and Linux platform
Java Applet
Applets are Java programs that run on java enabled web browser. Java applets can run on client servers with some restrictions. Applets are embedded into HTML...: There are various advantages of using Java Applets: They can run on any
 

 

 

DMCA.com