Java
  Home arrow Java arrow Page 9 - 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  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
JAVA

Java's Basic User Interface Components
By: Gayathri Gokul
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 15
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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 - Setting a Password Character
    ( Page 9 of 10 )

    The text Field allows you to specify an echo character that helps you accept a password without displaying what the user has keyed in. For example, say you have specified “*” as the echo character, and the user type in five character, “*****” is displayed in the text filed instead of the text the user has keyed in. To do this, first create the text field itself; then use the setEchoCharacter() method to set the character that is echoed on the screen. Here is an example:

    TextField tf = new TextField(30); tf.setEchoCharacter('*');

    The Applet in Example7 below creates several text fields. Labels are used to identify the fields. One of the fields uses an obscuring character to hide text being input. This applet uses the default layout manager, the only thing causing the six components to appear in three different lines is the width of the window.

    /*
    <Applet code= “TextfieldTest.class”
    Width = 400
    Height = 150>
    </Applet>
    */

    Import java.awt.*;
    Public class TextfieldTest extends java.applet.Applet
    {
    Label uLabel = new label (“User Name:”);
    TextField uText = new TextField (25);
    Label eLabel = new label (“Email ID:”);
    TextField eText = new TextField (25);
    Label pLabel = new label (“Admin Password:”);
    TextField pText = new TextField(25);

    Public void init(){
    add(uLabel);
    add(uText);
    add(eLabel);
    add(eText);
    add(pLabel);
    pText.setEchoCharacter(‘*’);
    add(pText);
    }
    }


    After creating the controls, we initialize them using the “new” keyword. Use the add() method to add controls to the container, in this case the applet. The other methods for TextField are:

    Method Action
    String getText() Extracts the text from the text field (as a string).
    Void setText(String str)Sets the text of the text field to the text specified in the str.
    Int getColumns()Returns the width of this text field.
    select(int, int) Selects the text between the two integer positions (positions start from 0)
    selectAll() Selects all the text in the field
    Boolean isEditable ()Returns true or false based on whether the text is editable
    Char getEchoChar()Returns the character used for masking input
    Boolean echoCharIsSet(char c) Returns true or false based on whether the field has a masking character


     
     
    >>> More Java Articles          >>> More By Gayathri Gokul
     

       

    JAVA ARTICLES

    - Exception Handling Techniques in Java
    - More About Multithreading in Java
    - The Basics of Multiple Threads in Java
    - Data Access Using Spring Framework JDBC
    - New Object Initialization in Java
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek