Home Java Example Java Awt AWT Components
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

AWT Components

Advertisement
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 components shown below directly extend Component like Button, Canvas, Label etc.

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 components shown below directly extend Component like Button, Canvas, Label etc. 

Buttons

As shown in the example below, a button is represented by a single label. That is the label shown in the example can be pushed with a click of a mouse.

 

 

import java.awt.*; 
import java.applet.Applet; 
 
public class MyButton extends Applet 
  public void init() { 
  Button button = new Button("SUBMIT")
  add(button)
  

Here is the HTML code:

<HTML>
<HEAD>
</HEAD>
<BODY>
<APPLET ALIGN="CENTER" CODE="MyButton" WIDTH="400" HEIGHT="200"></APPLET>
</BODY>
</HTML>

Here is the Output:

C:\newprgrm>javac MyButton.java

C:\newprgrm>appletviewer MyButton.html

C:\newprgrm>

 

Download this example.

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 13, 2008

Ask Questions?    Discuss: AWT Components   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Sourabh
September 15, 2011
Good tutorial

A big thanks to you for providing such an Excellent tutorial.
pravin
March 17, 2012
awt

Wrong awt appletviewer run & many cord mastic.
DMCA.com