Netbeans form editor and JFormattedTextField

M

Mack Attack

The Netbeans form editor uses parameterless constructors for all components.
I don't think there is any way around this.

I want to use a JFormattedTextField and have it set to use a specific format.
If I wasn't using the form editor I would do something like this:

NumberFormat percentFormat = NumberFormat.getNumberInstance();
percentFormat.setMinimumFractionDigits(3);
myFormattedTextField = new JFormattedTextField( percentFormat );

How can I do the same thing with the JFormattedTextField created by the form?
I've looked at setFormatter and setFormatterFactory but they have me completely
confused.

Thanks
 
C

Christophe Vanfleteren

Mack said:
The Netbeans form editor uses parameterless constructors for all
components. I don't think there is any way around this.

I want to use a JFormattedTextField and have it set to use a specific
format. If I wasn't using the form editor I would do something like this:

NumberFormat percentFormat = NumberFormat.getNumberInstance();
percentFormat.setMinimumFractionDigits(3);
myFormattedTextField = new JFormattedTextField( percentFormat );

How can I do the same thing with the JFormattedTextField created by the
form? I've looked at setFormatter and setFormatterFactory but they have me
completely confused.

Thanks

Select the JFormattedTextField in the gui designer.
Then go to the "code generation" tab of the properties panel.
Select the "custom creation code" field.
Type "new JFormattedTextField( percentFormat );" (without the quotes
ofcourse) in the field.

You can also set the Numberformat part in the
"pre-creation code" field.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top