Pages

Monday, November 23, 2009

How to Add Formatted Text Field in Netbeans: Limit the Input in Java Text Field

---

Formatted text field is a feature in Java programming that lets you control the input in your JTextFields.

In Netbeans IDE, you cannot just edit the codes anywhere you like it if the GUI is generated by the IDE. This may mean that putting your formatting code would take you some time by overriding the class, function, etc (That's how you usually customize Netbeans - generated codes). However, there's a shorter way to do that, follow these steps:


1. Right click on the JFormattedTextField and select Customize Code

click the image for a larger view

2. Code it!

Be sure you get to see the Code Customizer dialog box of Netbeans that look like this:


Note 1: Declare and instantiate the Maskformatter just once.

Note 2: Define the maskformatter. Search the net for ways you could manipulate the MaskFormatter's functions :P

***

1 comments:

Anonymous said...

thanks for the example :)
-DMM

Post a Comment