Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

TextField in awt

 
sun moon
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I want to limit upto 5 characters the in textfiled.
please help me out in this
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sun moon" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

There's actually already an answer to your question in this post.

Thanks! and welcome to the JavaRanch!
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you had read the API documentation you would know that it is as simple as:
TextField tf = new TextField(5);
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nigel that does not limit the user to 5 characters. That only applies to display.
 
Rama Ituarte
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a class that extends javax.swing.text.PlainDocument. In you subclass override the insertString(in,String,AttributeSet) method.
Rama
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!