SunQuest
 
       Java
  Home arrow Java arrow Page 10 - 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 
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

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

    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

    Java's Basic User Interface Components - TextArea


    (Page 10 of 10 )

    The TextArea is an editable text field that can handle more than one line of input. Text areas have horizontal and vertical scrollbars to scroll through the text. Adding a text area to a container is similar to adding a text field. To create a text area use one of the following constructors:

    • TextArea() creates an empty text area with unspecified width and height.
    • TextArea(int, int) creates an empty text area with indicated number of lines and specified width in characters.
    • TextArea(String) creates a text area initialized with the given string.
    • TextField(String, int, int) creates a text area containing the indicated text and specified number of lines and width in the characters.
    The Applet in Example 8 displays a text area that is filled with a string, when the programs begins running using appletviewer.

    /*
    <Applet code= “TextAreaTest.class”
    Width = 250
    Height = 450>
    </Applet>
    */

    Import java.awt.*;
    Public class TextfieldTest extends java.applet.Applet
    {
    String letter = “Dear Readers: \n” +
    “We are learning about Java AWT. \n” +
    “Some of you might find it all exciting, while a few are still not very sure \n” +
    “For those cat on the wall folks \n” +
    “My advice is read it again and practice some codes. \n \n” +
    “So brewing a cup of Java? Isn’t so hard as it looked…is it! ” ;

    TextArea ltArea;

    Public void init(){
    ltArea = new TextArea(letter, 10, 50)
    add(ltArea);
    }
    }


    The TextArea, like TextField, can use methods like setText(), getText(), setEditable(), and isEditable(). In addition, there are two more methods like these. The first is the insertText(String, int) method, used to insert indicated strings at the character index specified. The second is replaceText(String, int, int), used to replace text between given integer position with the indicated string.

    It's this sort of real work in Java applets and applications for which Java's Abstract Windowing Toolkit, or AWT, was designed. You've actually been using the AWT all along, as you might have guessed from the classes you've been importing. The basic idea behind the AWT is that a graphical Java program is a set of nested components, starting from the outermost window all the way down to the smallest UI component. Components can include things you can actually see on the screen, such as windows, menu bars, buttons, and text fields, and they can also include containers, which in turn can contain other components. Hope you have got a clear picture of Java AWT and all the basic UI components, in the next part of the tutorial we will deal with more advance user interface components.
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

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