Masked JTextFields

I

Ike

Is there a way, for a given JTextField, to mask it? In other words, is there
a way by which to make it so that the data must be put in as HH:mm:ss say?
Such that the user would see (if there were nothing in the field):
HH:mm:ss

With a Document then that only allowed numeric entried in all but the 2nd
and 5th character positions (where no matter what was typed, you;d only see
":". I know how to do a Document that shows this, but how can you actually
make it "masked" so it appears like a masked field? Thanks, Ike
 
P

Paul Hamaker

import javax.swing.text.MaskFormatter;

MaskFormatter mf = new MaskFormatter( "##:##:##" );
tf = new JFormattedTextField ( mf ) ;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top