Listener for textbox when user click


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Listener for textbox when user click

  1. #1
    Join Date
    Mar 2005
    Posts
    31

    Question Listener for textbox when user click

    Hi,

    I have a TextField box with some default text inside. How can I make it like those HTML forms which when user click the textbox, the default text will be switch become empty string?

    TIA

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    JTextField has its own ActionEvent s and handlers. As a JComponent it also has KeyEvent(s) and MouseEvent(s). From one or more of these events you can fashion the behavior you say you want.

  3. #3
    Join Date
    Mar 2005
    Posts
    31
    Any example? I tried ActionEvent evt and e.getSource() method and it doesn't seems to recgonised..

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    The "action events" listened for by an action listener would be a button press or other such action on a component. Since you are looking to respond to a user's mouse click, why not listen for a mouse event?

    you're looking to listen for a mousePressed event

    http://java.sun.com/docs/books/tutor...elistener.html
    Last edited by nspils; 07-23-2007 at 11:31 AM.

Similar Threads

  1. Replies: 6
    Last Post: 07-08-2006, 10:48 PM
  2. Connecting to DB2 using VB 6.0
    By Randy in forum VB Classic
    Replies: 5
    Last Post: 03-30-2001, 09:13 PM
  3. Let the user install DAO with a click ..
    By MrRolf in forum VB Classic
    Replies: 3
    Last Post: 03-19-2001, 06:53 PM
  4. Adding New NT User Account
    By John Whitney in forum VB Classic
    Replies: 2
    Last Post: 02-01-2001, 11:15 PM
  5. Replies: 2
    Last Post: 12-01-2000, 11:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center