Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Easy Question JTextFields

Posted on 2004-10-07
5
Medium Priority
?
233 Views
Last Modified: 2010-03-31
Simple really

How do I set a JTextField, for example:

JTextField MyName = new JTextField(10);

So that when I add the TextField to a panel it accepts ONLY 10 characters and no more. When I add a TextField like this to a panel, you can type as much as you like. Is there a way of making only allow you to type in the max number of characters I specify?

I've seen reference to this on the net, but can't locate an answer.
0
Comment
Question by:zaphod_beeblebrox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 120 total points
ID: 12247629
0
 

Author Comment

by:zaphod_beeblebrox
ID: 12247651
Points well deserved zzynx!

0
 
LVL 37

Expert Comment

by:zzynx
ID: 12247689
Thanks
0
 

Author Comment

by:zaphod_beeblebrox
ID: 12249267
Just thought I'd add the following.

The top example, quotes:

"import com.sun.java.swing.text.*;"

This will only work with older versions of Java.
If you're having problems change it to

"import javax.swing.text.*;"

and it works perfectly.

Took me a while to figure that one out...(DOH!)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question