Jav Applets

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 labels to identify all three text fields and a button to calculate the result.

Thanks
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
ModuleNotFoundError: No module named 'jav'
ModuleNotFoundError: No module named 'jav'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'jav' How to remove the ModuleNotFoundError: No module named 'jav' error
ModuleNotFoundError: No module named 'jav'
ModuleNotFoundError: No module named 'jav'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'jav' How to remove the ModuleNotFoundError: No module named 'jav' error
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
applets
Applets
Applets
Applets
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
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
jav - Spring
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
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
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
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
java applets - Applet
Animation in Applets - Applet
Applets - IDE Questions
java applets - Java Beginners
regarding applets - Java Beginners
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.
Problem with display of images in applets - 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... of Applet? Applets are cross platform and can run on Windows, Mac OS and Linux
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..._TO_REPLACE_1 There are various advantages of using Java Applets: They can
Applet versus Application
;    Applets as previously described, are the small programs while applications are larger programs. Applets don't have the main method while in an application execution starts with the main method. Applets can run in our
Free Java stuffs
Java apps for cell phonesADS_TO_REPLACE_2 Free Java Applets
&lt;APPLET&gt; Tag Parameters: The &lt;PARAM&gt; Tag
directly to a Java applet. Parameters are to applets what command-line... to applets are: First, add the PARAM tag (with values) to the HTML source file... the Applet These parameter values are retrieved by Java applets using
Java JAR Files
Java JAR Files       A JAR file is a collection of  class files and auxiliary resources associated with applets and applications. The Java Archive (JAR) file format enables
Java Update
Update 2 provides improved behavior for applets in Safari and increased stability... run applets and Web Start applications without waiting for the whole JRE... the requirements of most Java applets and applications and any additional libraries
Java hello world
Java hello world       Java is a high-level object-oriented programming language developed by the Sun Microsystems and is available in different form like JSP, Java Applets, J2EE
Applet
; Introduction Applet is java program that can be embedded into HTML pages. Java applets... restrictions on it. Applet can't access system resources on the local computer. Applets... of Applet:ADS_TO_REPLACE_1 Applets are cross platform and can run on Windows
The Java Applet Viewer
; Applet viewer is a command line program to run Java applets... that inherits the Applet. We generally use web browsers to run applets. Its not always... that acts as a test bed for Java applets. The working of Applet viewer is a bit
The Java Applet Viewer
is a command line program to run Java applets. It is included in the SDK. It helps you... generally use web browsers to run applets. Its not always mandatory to open a Web... as a test bed for Java applets. The working of Applet viewer is a bit different from
Using Applet in JSP
be embedded into HTML pages. Java applets runs on the java enables web browsers... resources on the local computer. Applets are used to make the web site more dynamic
The Java Applet Viewer
; Applet viewer is a command line program to run Java applets... the Applet. We generally use web browsers to run applets. Its not always... that acts as a test bed for Java applets. The working of Applet viewer is a bit
Applet in Java
the java.applet.Applet class Applets are also useful for a small Internet and intranet... are viewed through Java-enabled web browsers. Advantages of Applet: Applets can run on Windows, Linux and Mac OS Applets are secure Almost all web
Java applet
Java applet  what are types of applets
Java basics
Java basics  Differences between applications and applets
java - Java Beginners
Java applets programs coding  Java applets programs coding and example.Thanks in Advance
<APPLET> Tag Parameters: The <PARAM> Tag
Swing In Java

Ads