JFormattedTextField_Phone is not formatting

I wrote this simple applet using netbeans 3.6 IDE -
The applet has 3 formatted textFields (which does not format)
Date mm/dd/yyyy
Tel (123) 333 4444
Price #,###
Can you please help - why the format is not working.
Thanks
//Here is the code
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
import java.util.*;
import java.text.*;
public class aFormat extends javax.swing.JApplet {
/** Initializes the applet aFormat */
public void init() {
initComponents();
setUpField_Date();
setUpField_Phone();
setUpField_Money();
private void setUpField_Date() {
// date format
DateFormat format = new SimpleDateFormat("MM/dd/yyyy");
DateFormatter df = new DateFormatter(format);
this.jFormattedTextField_Date = new JFormattedTextField(df);
this.jFormattedTextField_Date.setValue(new Date());
private void setUpField_Phone() {
// US telephone number
try {
MaskFormatter mf2 = new MaskFormatter("(###) ###-####");
this.jFormattedTextField_Phone = new JFormattedTextField(mf2);
} catch (java.text.ParseException exc) {
System.out.println("Exception formatting");
private void setUpField_Money() {
// money format
this.jFormattedTextField_Money.setText("0.00");
this.jFormattedTextField_Money = new JFormattedTextField(new DecimalFormat("#,###"));
/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jFormattedTextField_Date = new javax.swing.JFormattedTextField();
jLabel2 = new javax.swing.JLabel();
jFormattedTextField_Phone = new javax.swing.JFormattedTextField();
jLabel3 = new javax.swing.JLabel();
jFormattedTextField_Money = new javax.swing.JFormattedTextField();
getContentPane().setLayout(null);
jLabel1.setText("Date (MM/DD/YYYY)");
getContentPane().add(jLabel1);
jLabel1.setBounds(4, 20, 160, 20);
getContentPane().add(jFormattedTextField_Date);
jFormattedTextField_Date.setBounds(170, 20, 130, 21);
jLabel2.setText("Tel ( ___ )-___-____");
getContentPane().add(jLabel2);
jLabel2.setBounds(0, 50, 150, 20);
getContentPane().add(jFormattedTextField_Phone);
jFormattedTextField_Phone.setBounds(170, 50, 130, 20);
jLabel3.setText("Price");
getContentPane().add(jLabel3);
jLabel3.setBounds(0, 80, 130, 20);
getContentPane().add(jFormattedTextField_Money);
jFormattedTextField_Money.setBounds(170, 80, 130, 21);
// Variables declaration - do not modify
private javax.swing.JFormattedTextField jFormattedTextField_Date;
private javax.swing.JFormattedTextField jFormattedTextField_Money;
private javax.swing.JFormattedTextField jFormattedTextField_Phone;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
// End of variables declaration

The problem is that you are adding the components in the initComponets() method and then overlaying their references with new components with the applied mask format. The original components are still present on the panel. You've simply orphaned the references to those original components not replaced them on the panel. See adjusted code below:
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
import java.util.*;
import java.text.*;
public class aFormat extends javax.swing.JApplet {
/** Initializes the applet aFormat */
public void init() {
initComponents();
//setUpField_Date();
//setUpField_Phone();
//setUpField_Money();
validate();
private void setUpField_Date() {
// date format
DateFormat format = new SimpleDateFormat("MM/dd/yyyy");
DateFormatter df = new DateFormatter(format);
this.jFormattedTextField_Date = new JFormattedTextField(df);
this.jFormattedTextField_Date.setValue(new Date());
private void setUpField_Phone() {
// US telephone number
try {
MaskFormatter mf2 = new MaskFormatter("(###) ###-####");
this.jFormattedTextField_Phone = new JFormattedTextField(mf2);
} catch (java.text.ParseException exc) {
System.out.println("Exception formatting");
private void setUpField_Money() {
// money format
this.jFormattedTextField_Money.setText("0.00");
this.jFormattedTextField_Money = new JFormattedTextField(new DecimalFormat("#,###"));
/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
DateFormat format = new SimpleDateFormat("MM/dd/yyyy");
DateFormatter df = new DateFormatter(format);
this.jFormattedTextField_Date = new JFormattedTextField(df);
this.jFormattedTextField_Date.setValue(new Date());
jLabel2 = new javax.swing.JLabel();
try {
MaskFormatter mf2 = new MaskFormatter("(###) ###-####");
this.jFormattedTextField_Phone = new JFormattedTextField(mf2);
} catch (java.text.ParseException exc) {
System.out.println("Exception formatting");
jLabel3 = new javax.swing.JLabel();
this.jFormattedTextField_Money = new JFormattedTextField(new DecimalFormat("#,###"));
this.jFormattedTextField_Money.setText("0.00");
getContentPane().setLayout(null);
jLabel1.setText("Date (MM/DD/YYYY)");
getContentPane().add(jLabel1);
jLabel1.setBounds(4, 20, 160, 20);
getContentPane().add(jFormattedTextField_Date);
jFormattedTextField_Date.setBounds(170, 20, 130, 21);
jLabel2.setText("Tel ( ___ )-___-____");
getContentPane().add(jLabel2);
jLabel2.setBounds(0, 50, 150, 20);
getContentPane().add(jFormattedTextField_Phone);
jFormattedTextField_Phone.setBounds(170, 50, 130, 20);
jLabel3.setText("Price");
getContentPane().add(jLabel3);
jLabel3.setBounds(0, 80, 130, 20);
getContentPane().add(jFormattedTextField_Money);
jFormattedTextField_Money.setBounds(170, 80, 130, 21);
// Variables declaration - do not modify
private javax.swing.JFormattedTextField jFormattedTextField_Date;
private javax.swing.JFormattedTextField jFormattedTextField_Money;
private javax.swing.JFormattedTextField jFormattedTextField_Phone;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
// End of variables declaration
}

Similar Messages

  • I've been using FCP 7 on my iMac for quite some time with great success.  Lately I created a new project and the browser window does not format properly (it's O.K. for previously created projects). The effects window is also not displaying properly.

    Help! My browser window is suddenly not formatting properly. (losing browser formatting, glitch, bug)  I'm using FCP 7 on an iMac with OS X 10.8.5 and have been successfully doing so for a couple of years.  I fear my Final Cut Pro is corrupt and I have to re-install. Anyone ever see this problem? Old projects display and behave fine in the browser, but any new project I create, totally loses the formatting in the browser and the browser also does not display the "effects" window properly anymore. (see below)

    YOU ARE A LIFE SAVER!  I reinstalled the program and everything. THANK YOU! THANK YOU! MY HERO!!!

  • When I load Windows 7 in Bootcamp it freezes saying partition is not formatted for NTFS(?)

    I have to set up a partition on my new iMac to get a piece of business software to load. I tried Crossover and Parallels. Set up a 250 GB partition in Bootcamp and things seemed to be going fine with the windows 7 Ultimate loading but then i get a message like Hard drive not formatted for NTFS. Suggestions

    I Just figured it out!  I Have a Mac Mini 2012 with 2  Kingston 128 GB SSDs.  I thought it was having 2 internal drives that was making problems... Had exact same issue as all of you.   First I would get a no NTFS partition error after I used Boot Camp Assistant to make a USB install stick for Windows 7 Ultimate x64.
    My solution was simple, removing EVERYTHING connected to my mac mini, including my Wireless mouse and Keyboard. All I had connected was my Apple wired keyboard, the install USB drive, and my monitor. Having a Second internal SSD drive was not the issue.
    I formatted the BootCamp partition, and POW! it actually worked.  The error that  setup couldnt install on this drive, and see error log didnt show up!  Try that! it might work!

  • On windows 7 my itunes 11 opening screen is not formatted correctly. How do I formatt itunes 11 welcome screen?

    on windows 7 my itunes 11 opening page is not formatted and looks different than itunes 11 ads  and formatting. How do I get to the itunes 11 welcome screen?

    I have not seen your error in either my IE or my chrome. I do note that you are using a "strict" Document Type Declaration.
    You might try a transitional DTD, which should be more forgiving than the strict:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    Other than that, I don't see anything particular (because I don't see the error, either) that would cause the menu to drop vertically instead of horizontally.
    Beth

  • Disk Utility will not format/erase/partition an unformatted scsi disk

    Well, I'm back with a RAID problem again. This time the powers that be sent me a Sun Microsystems StorEDGE A5200 RAID box (22 33gig disks). It's a fibre channel system, and is full of Seagate FC disks. The box only hooks up to my G5 Quad via the Apple Fibre channel card that I have hooked up. It's a dual channel card and both are plugged into the back of the RAID array.
    Now, here's what I have.....
    The Drives show up in both Disk Utility and Anubis
    The is only one drive formatted and it works fine.
    All the rest of the drives are unformatted (not just blank, but without any operating system on them, just like they were fresh out of the box)
    Attempting to Erase a disk results in the message
    Disk erase failed
    Disk erase failed with the error:
    Invalid Argument
    Attempting to Partition a disk results in the message
    Partition failed with the error:
    Invalid Argument
    Attempting to create a RAID set results in the message
    Creating RAID set failed with the error:
    Could not add a RAID disk to a RAID. (note there was no other RAID set)
    Only one disk in the array is formatted and it will respond to all of the functions in Disk Utility.
    I was told that I needed to do something using the command line, but that was pretty vague as to what I needed to do. Apparently I need some sort of superuser authority to get these drives formatted, and that's it's not documented any where.
    So folks, I leave it up to you again, what do I do?

    OK, I have found out much in the last few weeks.
    1 - Apple no longer supports SCSI, you may not format disks in any way using OS X. OS 9 also does not work on any of the G5 machines at least.
    2 - You can use Linux to do most of the work with SCSI, it is still supported, although there is little clear documentation on how to get it done. Linux is free and works very well with my G5 Quad. But it has a steep learning curve and it's not worth it for just formatting SCSI drives.
    What I found out about my SCSI drives turned out to be the core of all the problems I have had, and it was Linux that found the problem. Seems all of the drives I have but one have been formatted in such a way that only the proprietary operating system that formatted them would read them. 520k data blocks. I reformatted several of the drives to 256k blocks and they work fine now.
    Before I go out and start going though this for a few hundred more of these drives, my academic supplier found just as many drives that were specifically formatted for use in Sun RAIDs and are properly recognized by OS X, and with twice the drive space (current is 36gig, new ones are 73gig). He is sending me 44 of them (and a second RAID box)
    I'm hoping that this finally solves the problem and hope all will be working soon.

  • ICloud you have the ability to NOT format phone numbers of contacts; this ability is not available on the contacts of iPhone. If I set-up a phone number in iCloud with NO parenthesis, ex. 123- 456-7899, then this format should be available on the iPhone

    In iCloud you have the ability to NOT format phone numbers of contacts; this ability is not available on the contacts of iPhone. If I set-up a phone number in iCloud with NO parenthesis, ex. 123- 456-7899, then this format should be available on the iPhone contact.

    That is correct is doesn't. Standardized formatting of phone numbers in the iOS app is more important because it supports contact from a variety of locations (gmail, hotmail, etc.). iCloud doesn't (not directly).

  • I recently purchased a book from itunes on my ipad 2 but when i open the book in ibooks i get (incorrectly formatted or not formatted for ibooks) somebody please help

    I am currently deployed over seas.. I recently purchased a book that im pretty stoked about. but when i open it in ibooks i get ( incorrectly formatted or not formatted for ibooks to recognize) the file is an .epub so i dont see how it could be a format issue.. I tried emailing apple but because of the situation they want me to call. I have very limited telecomminications at my location .. somebody please help

    The Report a Problem link can also be found in iTunes/Store/View Account/Purchase History.
    Before asking for a refund, also try deleting the book and redownloading it.
    If you find that the iBookstore is does not meet your needs, you can try one of the others like Kindle, Nook, Kobo, Googlebooks, or Sony.
    To let Apple know your views on their apps or services, use
    http://www.apple.com/feedback

  • USB Drive (Toshiba 16GB PA3875A-1MAB) Not formatted message

    Some months ago I purchased two 16GB USB drives with intention to use as a convenient backup for certain data files for myself and my wife on separates PCs, both of which were Dell desktops running Windows XP. I used my drive on a few occasions thinking all was OK until one day I found some files and folders were inaccessible with total rubbish (folder and files names were mixed symbols rather than normal alpha characters as used).
    Disaster struck with both our PCs beginning to fail, so it became paramount to backup on other media as quickly as possible, and to start the hunt for replacement PCs. We decided on HP desktops with Windows 7 64 bit, using i5 and i7 processors. After many weeks of frustration, (HP don't bother to even tell you what software comes with your machine, or why I have some weird looking accessories left over) almost all perephirals - scanners, printers - have either been replaced or later drivers downloaded and installed, putting the subject of this post into low priority.
    However, I have now connected my USB drives, and received the usual Windows message that the "Device driver software installed successfully. Your device is ready to use". So far so good. The drive is neatly shown in Windows Explorer, but when I click on the drive, I get a dreaded Windows message "You need to format the disk in drive L: before you can use it. Do you want to format it?"
    Having never had such a message with a USB drive before, and being brought up on the premise that formatting a drive is a last resort to be avoided at all costs, I tried to see what properties Windows would reveal to me. Low and behold, under the Hardware tab, I am informed that "This device is working properly"! But the General tab also tells me that the drive has used 0, and has free 0. I am also reliably informed that the file system is "FAT"
    I have tried putting the drives into different USB ports, and the same messages come up. All my other USB drives of various makes and sizes work without a hitch in any of the USB ports.
    I plugged the drive into my old Windows XP notebook and the drive immediately showed up in Windows Explorer, without any notification of drivers being installed. However, clicking on the drive elicits a Windows message "The disk in drive F: is not formatted - do you want to format it now? The Properties tell me the file system is "RAW", and of course it says that the device is working properly.
    I do not need to recover the data on the USB drive, as I have several other modes of backup that I use (redundancy is a great thing when things go wrong), but I would be very interested to learn whether anyone else has experienced the same thing, and what they did about it. If I do select "Format" what system should I use (if given an option) - I have read that FAT32 is good for drives up to 4 GB, but after that NTFS is the better option. I am also aware that the drive originally had been partitioned with Toshiba "Lock" technology, and that formatting will wipe out all of this. Toshiba's website makes no mention of this issue (that I could locate after extensive searching).
    Or should I merely take the USB drives back to my retailer and tell them they do not work correctly, and claim against my warranty? Probably the least hassle for me, unless Toshiba want to argue that it is a normal functioning of their product, and charge me for the privilege.
    All constructive answers would be very much appreciated.

    Thanks for reply. You are quite correct. I took the drives back to my retailer who tested them on their own equipment, and then told me "there is definitely something wrong with them", and immediately offerred replacing them with two new ones - which do work! Nice to know that there are retailers out there who do the right thing by their customers.

  • My 4th gen. shuffle keeps on sending me an error message that it cannot connect with iTunes because it's not formatted properly.

    Hi,
    About two days ago my shuffle started to send me an error message that it cannot connect with iTunes because it's not formated properly.
    So I've already updated the softwer, I tried to use it with every single USB port on my computer and searched for solutions on the net but couldn't find any useful information...
    I literally see the following message: The iPod "194" cannot be used with iTunes because it is not formatted properly.
    Any ideas?....
    Thank you!

    If you cannot access the iPad because of the passcode, you have no choice but to restore it using the same steps that you would use if you forgot the passcode.
    iOS: Forgotten passcode or device disabled after entering ...

  • The header photos on my website are not formatting properly in Mozilla. How do I fix this?

    Hi There,
    The header photos on each page of my website are not formatting properly in Mozilla. The photos appear to the right side of the website and you have to scroll over to see them. They work on other browsers such as Chrome and Safari. How do I fix this? Here is the link to my website: http://cpd.berkeley.edu/.
    Thanks for your help!

    What is even stranger, is if you reload the page in version 33, it is in the right place. Does this happen on Beta? [https://www.mozilla.org/en-US/firefox/channel/]
    If this continues, please clear the cache and refresh the page, then if it still happens please webcompat.com file a bug here.

  • Media card will not format

    I have not been able to format my media card. My phone does recognize it. But will not format for the blackberry pearl 8120 . HELP, I have done everything, and cant get it to format. I know I have the correct disk It is a scandisk 1.0gb Micro SD.

    hello,
    I strongly advise you to format the memory card with something else than the Blackberry. If you really have to do it from the blackberry, the procedure is here :
    http://www.blackberry.com/btsc/search.do?cmd=displayKC&docType=kc&externalId=KB10527&sliceId=SAL_Pub...
    The search box on top-right of this page is your true friend, and the public Knowledge Base too:

  • Safari not formatting the page

    I have Safari running on Mac OS 10.6 with an  Intel iMac.
    The system has 2 accounts on it.   Admin and User.
    When I log on as the User acount, and launch Safari, some web sites do NOT format correctly.  
    Safari OR Firefox do NOT show the fonts correctly, spacing is off, and alignment is messy.  
    I have tried Firefox, No change the same bad format.
    HOWEVER when I log on as the Admin user.    Safari and Firefox work correctly.
    FiXES;
    I have removed the Prefenece folder from the User account. 
    Logged off, then back on again.  Safari created all new prefences, and still the same formatting issues.
    Any suggestions??
    where do I look?
    Thanks
    Larry

    I was think of creating another account tomorrow.
    Then moving the files over to the new ~/library folder, one folder at a time.
    It has to be in the ~/Library folder.
    Was hoping some would know the answer.
    Just don't know which folder or file it would be.
    Sort of like troubleshooting OS 9 again.  lol
    I WILL post my findings.
    thanks.
    larry

  • File not formatted correctly error

    Dear All,
    when am trying to import a contract file as excel sheet, not CVs file, i get the error ( File not formatted correctly ). any advice?

    the issue with date formatting would be corrected in Excel. When an export file that includes dates is opened in Excel, they get reformatted by the Excel program. In my experience, I have had to reformat those cells in Excel to the YYYY-MM-DD format and save the Excel file before I could import again into CM. But, if you are just exporting and then importing without opening the file in Excel, then the dates are not the problem. What are you exporting from CM? Are you trying to import into a different project or database than you exported from?

  • Cfdocument format = PDF - does not format correctly

    Greetings
    I am simply attempting to print invoices from a query that displays correctly on the cfm result page, but using cfdocument to render a PDF version (to mail out) does not format even remotely close to the cfm page.
    I tried every conceivable method I know of, including:
    Formating the cfm page (via CSS and hardcoded table width) to be 612 px X 792 px (8.5 X 11 in), and here is the cfdocument code:
    <cfdocument
    format="pdf" 
    pageType="custom"
    unit="in"
    marginbottom="0.75"
    marginleft="0.75"
    marginright="0.75"
    margintop="0.75"
    pageHeight="11"
    pageWidth="8.5"
    mimeType="text/html"
    fontembed="yes"
    orientation="portrait">
    <style type="text/css">
    @import url(css/moorings.css);
    </style>
    <html> blah blah </html>
    </cfdocument>
    The rendered PDF file is 4.5 X 5 in- (both in IE and Firefox) What am I missing here?
    CF 9
    Thanks in advance, as always.

    Well, in answer to my own question, the solution is in the CSS, using tables and CSS:
    set table height and width to 100%
    set font-size:100%;
    set header font, bolder, larger :125%;, etc.
    Also using the cfdocument attributes as shown in the posting
    The PDF now prints correctly, margins are perfect.
    Now I have to figure out how to loop through the 900+ records, convert each to a PDF and print one copy of each-
    Anyone?
    Thanks....

  • Why a new trailers not formatting in hd play?

    Why are new trailers not formatting in HD play?

    On selecting full screen using the expand arrows in the video control panel in Safari 5.1.9 & OS 10.6.8; Trailer will expand to full screen and the screen will go black, but on selecting play there is no image or sound exept a faded outline of the edge of the Trailer frame that runs off screen and does not play.

Maybe you are looking for

  • Error in updating schema in SSM 7.0

    Hi, When I am updating schema in SSM 7.0, I am getting below error: An Error has occurred in the scipt on this page. Line:     67 Char:     3 Error:     'out1.1' is null or not an object Code:     0 URL:     http://<server:50000>/strategy/bi/admin_bi

  • Macbook airport issues! Help!

    I have a macbook and last year I was having trouble with the airport wireless. It would lose connection and I would have to restart the Linksys router to make the internet work again. I got fed up with it and decided to buy the apple airport extreme

  • Invalid Menu Handle

    I am using Adobe Reader XI.  I am unable to view or print a PDF document.   I keep getting the above message. This just started in the last two days after I deleted Adobe Photo Shop.  I uninstalled all Adobe Programs and re-installed Adobe Reader to

  • Corrupted Directory

    I just got my iPod and when I try to get music from iTunes, it is telling me that there is an error because the file or directory is corrupted and unreadable.

  • Line between images

    The images on this page have a line or space between them: http://www.dreams-catcher.net/twoimages_03.php There are 4 layers with a two cell table in each layer. Each cell has an image. There is NO cell padding or spacing. The images are the same siz