AWT Tutorials

AWT Tutorials

How can i create multiple labels using AWT????

View Answers

February 16, 2011 at 11:37 AM

Java Applet Example multiple labels

1)AppletExample.java:

   import javax.swing.*;
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;

    public class AppletExample extends Applet implements ActionListener {
      TextField input1,input2,output;
      Label label1,label2,label3;
      Button b1;
      int num1,num2, sum = 0;
      public void init(){
        label1 = new Label("Number 1: ");
        add(label1);
        input1 = new TextField(5);
        add(input1);
        label2 = new Label("Number 2: ");
        add(label2);
        input2 = new TextField(5);
        add(input2);
        label3 = new Label("Sum : ");
        add(label3);
        output = new TextField(10);
        add(output);
        b1 = new Button("Add");
        add(b1);
        b1.addActionListener(this);
           }
      public void actionPerformed(ActionEvent ae){
        try{
          num1 = Integer.parseInt(input1.getText());
          num2 = Integer.parseInt(input2.getText());
          sum = num1+num2;
          output.setText(Integer.toString(sum));
         }
        catch(NumberFormatException e){
        }
      }
    }

2)applet.html:

<HTML>
<BODY>
<APPLET ALIGN="CENTER" CODE="AppletExample.class" width = "260" height = "200"></APPLET>
</BODY>
</HTML>

Ads









Related Tutorials/Questions & Answers:
AWT Tutorials
AWT Tutorials  How can i create multiple labels using AWT????   Java Applet Example multiple labels 1)AppletExample.java: import javax.swing.*; import java.applet.*; import java.awt.*; import
awt
Java AWT Applet example  how to display data using JDBC in awt/applet
Advertisements
awt
JDBC and AWT to display data  how to display data using JDBC in awt/applet
awt
JDBC in awt applet  how to display data using JDBC in awt/applet
awt
JDBC in awt  how to display data using JDBC in awt/applet
awt in java
awt in java  using awt in java gui programming how to false the maximization property of a frame
awt jdbc
awt jdbc  programm in java to accept the details of doctor (dno,dname,salary)user & insert it into the database(use prerparedstatement class&awt
AWT Image
AWT Image  I have loaded two images using toolkit in java.one is concentric rectangle and other is concentric circle.kindly someone send me the source code of interchanging the inner most rectangle with the inner most circle
java awt calender
java awt calender  java awt code for calender to include beside a textfield
another frame by using awt or swings
another frame by using awt or swings  how to connect one frame to another frame by using awt or swings
What is AWT in java
in java full tutorials We have described Interface and Description of AWT Package... What is AWT in java In this Example we will describe awt in java. The awt in java stands for Abstract Windowing Toolkit and is a package
java awt package tutorial
Java AWT Package In Java, Abstract Window Toolkit(AWT) is a platform... programming language, the AWT is also platform-independent. A common set.... The implementation of the user interface elements provided by the AWT is done using
Awt programming with java
Awt programming with java  Write a java program, which provides a text area with horizontal and vertical scrollbar.Type some lines in the text area and use scrollbars to move the text within the text area.Read a word in a text
Version of com.globalmentor>globalmentor-awt dependency
List of Version of com.globalmentor>globalmentor-awt dependency
Version of com.levigo>gwt-awt dependency
List of Version of com.levigo>gwt-awt dependency
date and time in awt(java)
date and time in awt(java)  sir, do you have an example of date in awt java which can be view over a textfield.   Display time in JTextField import java.util.*; import javax.swing.*; import java.awt.event.*; public
AWT Components
AWT Components       The class component is extended by all the AWT components. More of the codes can be put to this class to design lot of AWT components. Most of the AWT
Calling awt Frame methods from subclass
Calling awt Frame methods from subclass  Calling awt Frame methods from subclass
Photoshop tutorials
Photoshop tutorials  Hi, Where to learn Photoshop? Thanks   Hello, Check Photoshop tutorials home page. Thanks
JSP Tutorials
JSP Tutorials  Hi, I am confident in core java. I have learned if from roseindia.net. Now I want to learn JSP. Can anyone tell me JSP tutorials url... roseindia.net. Now you can learn Java Server pages at our JSP Tutorials section
java tutorials
java tutorials  Hi, Much appreciated response. i am looking for the links of java tutorials which describes both core and advanced java concepts in detail with examples in a systematic order.few links i found are discussing
C++Tutorials
other tutorials, such as C++: Annotations by Frank Brokken and Karel Kubat...; The CPlusPlus Language Tutorial These tutorials explain the C++ language.... We have a series of online courses and tutorials that will teach you either
Version of batik>batik-awt-util dependency
List of Version of batik>batik-awt-util dependency
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException   when i click on the SUBMIT button ON,OFF window is visiable first OFF button is clicking I getting the error : Exception in thread "AWT-EventQueue-0
Maven Dependency globalmentor-awt >> 0.5.0
You should include the dependency code given in this page to add Maven Dependency of com.globalmentor >> globalmentor-awt version0.5.0 in your project
Maven Dependency gwt-awt >> 0.0.2
You should include the dependency code given in this page to add Maven Dependency of com.levigo >> gwt-awt version0.0.2 in your project
Maven Dependency gwt-awt >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.levigo >> gwt-awt version1.0.0 in your project
Maven Dependency gwt-awt >> 0.0.1
You should include the dependency code given in this page to add Maven Dependency of com.levigo >> gwt-awt version0.0.1 in your project
Maven Dependency gwt-awt >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of com.levigo >> gwt-awt version1.0.1 in your project
how to print all colors using awt
how to print all colors using awt  how to print all colors using awt
Maven dependency for com.globalmentor - globalmentor-awt version 0.6.0 is released. Learn to use globalmentor-awt version 0.6.0 in Maven based Java projects
of globalmentor-awt released The developers of   com.globalmentor - globalmentor-awt project have released the latest version of this library on 13 Jun 2021, the released version of  com.globalmentor - globalmentor-awt library

Ads