Java
  Home arrow Java arrow Page 5 - Using Abstract Windowing Toolkit (AWT)...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Using Abstract Windowing Toolkit (AWT) In Applications
By: Gayathri Gokul
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2003-09-29

    Table of Contents:
  • Using Abstract Windowing Toolkit (AWT) In Applications
  • Read On….Its Not That Abstract
  • Your Best Buddies….Java’s AWT
  • Features Of The Component Class
  • What Holds Components Together…The Container
  • How To Talk To Your Application

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Using Abstract Windowing Toolkit (AWT) In Applications - What Holds Components Together…The Container


    (Page 5 of 6 )

    Containers:
    Some components can also act as containers. A window for example, can be a part of another container. At the same time it can be a parent to other components, such as textbox, and a checkbox, it is a container as well. The container class is a specialized subclass of the Component class. A container may contain zero or more components. These components are called siblings, since they have the same parent window. There are three main types of containers-Window, Applet and Panel. There are two types of windows-Frame and Dialog. A frame is a rectangular box with a title and resize button. A dialog box is similar to a frame except that it cannot be resized and does not have a menu bar.

    The Frame Class:
    A frame is a powerful feature of AWT. You can create a window for your application using Frame class. A frame has a title bar, resizable border and an optional menu bar. You can add components to the frame using add () method as frames are derived form java.awt.container. The Border layout is the default layout of the frame. A frame receives mouse events, keyboard events and focus events.

    The constructor of the Frame class receives the title of the frame as parameter. The string or name you specify will be displayed as the title of the frame.

    Frame f = new Frame (“Frame Window Demo”);
    After the window is created, it can be displayed by calling the setVisible () method and can be sized by calling the setSize () method. The program below displays a frame.
    Import java.awt.*; Public class frame extends Frame { Public static void main (String arg[]) { Frame frm; frm = new Frame(“My First AWT Container-The Frame”); frm.setSize(300,400); frm.setBackground (Color.red); frm.setVisible(true) } }

    Save the above program as frame.java, compile using Javac filename.java and execute using Java file name. The output will be a frame window with the title “My Frist AWT Container-The Frame”.

    More Java Articles
    More By Gayathri Gokul


     

       

    JAVA ARTICLES

    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway