• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JPasswordArea instead of JPasswordField

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am trying to get a large amount of data from the user via a JTextArea. However as the user types the data it appears in the textarea(normal behaviour). What I want is that a particular character appears on the screen no matter what character is pressed - A similar effect to the JPasswordField. I could use JPasswordField for this if pushed. However the user has to enter a lot of random data and I need a TextArea.
I want some actual character to appear on the screen so that the user knows that they have actually pressed a "good few" keys.
So, Is there a way to do this?
Regards,
Paul.
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can catch the keypresses with JavaScript and translate them as tehy go in to the field. Look up the JavaScript event model in any reasonable JavaScript book.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want the user to enter large amounts of data without being able to SEE what they are entering. Remind me not to use your application (I am a LOUSY typist).
If you go to the KeyEvent class of the API in the "see also" section they have a link to a tutorial on setting up key listeners.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To me this sounds like a random seeding method for something like generating security keys. In a case like this it's important that there is a lot of effectively un-duplicable input, so typos don't matter. Is my guess right? or do you have an even wierder use for blind typing?
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like what you want to have is your own Document, either by rolling your own on top of AbstractDocument or by subclassing PlainDocument. Depending on your needs, you can either make sure that everything getsentered into the Document as stars, or that nothing but stars are ever retrieved from the Document.
Maybe there is a simpler option. Have you considered looking into the source for JPasswordField?
- Peter
    Bookmark Topic Watch Topic
  • New Topic