Java
  Home arrow Java arrow Page 8 - Java's Basic User Interface Components
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 
Moblin 
JMSL Numerical Library 
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

Java's Basic User Interface Components
By: Gayathri Gokul
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2003-10-20

    Table of Contents:
  • Java's Basic User Interface Components
  • Adding a Control to a Container
  • The Button Class
  • The Label Class
  • The Checkbox Class
  • The CheckboxGroup Class
  • The Choice List Class
  • The TextField and TextArea Class
  • Setting a Password Character
  • TextArea

  • 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


    Java's Basic User Interface Components - The TextField and TextArea Class


    (Page 8 of 10 )

    To accept textual data from a user, AWT provided two classes, TextField and TextArea. The TextField handles a single line of text and does not have scrollbars, whereas the TextArea class handles multiple lines of text. Both the classes are derived from the TextComponent class. Hence share many common methods. TextFields are different from labels in that they can be edited; labels are good for just displaying text, while for getting text input from the user, the best option is TextField.

    TextFields provide an area where you can enter and edit a single line of text. To create a text field, use one of the following constructors:

    • TextField() creates an empty TextField with no specified width.
    • TextField(int) creates an empty text field with enough width to display the specified number of characters (this has been depreciated in Java2).
    • TextField(String) creates a text field initialized with the given string.
    • TextField(String, int) creates a text field with specified text and specified width.


    For example, the following line creates a text field 25 characters wide with the string "Brewing Java" as its initial contents:

    TextField txtfld = new TextField ("Brewing Java", 25);add(txtfld);

    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 5 hosted by Hostway