How do I turn off percent symbol in JFormattedTextField

I am using a custom JFormattedTextField field, that has methods to add masks which apply formatting and add suffix and prefixes.
It allows the user to see the data in display mode (formatted) or raw (unedited mode)
Just found a problem though with our display mode when I try and add a suffix of a % symbol after the text.
It turns out that JFormattedTextField does magic when it sees a %.
It assumes I want to multiply the data by 100, which I do not. (the data is already stored in terms of percent.)
I found an ugly hack to solve my problem, which is:
  DecimalFormat displayFormat = new DecimalFormat();
  DecimalFormatSymbols dfs = displayFormat.getDecimalFormatSymbols();
  dfs.setPercent('~'); // set to a symbol we will never use 
  displayFormat.setDecimalFormatSymbols(dfs);
  this.setFormatterFactory(new DefaultFormatterFactory(new NumberFormatter(displayFormat)));
  // then later we apply our mask
  // used to do this
  // displayFormat.applyPattern(myDisplayFormat);
  // now have to do this so it does not overwrite our percent symbol
  this.displayFormat.applyLocalizedPattern(myDisplayFormat);It seems like there should be an easier way to accomplish this.
What I was really hoping I could do, is "turn off" the percent substitution functionality.
i.e. something like displayFormat.disablePercentFormatting(true);
but at the moment, messing with localised symbols seems like the only way to hack it.
Anyone have any thoughts? I just want DecimalFormat not to treat a % as a special symbol.
note:
Changing the data itself (dividing it by 100) is not an option as the data is entered elsewhere and it would screw up the raw view of the data too.
Changing the underlying framework (of how we use our display / edit fields and masks etc) is not an option
as there are hundreds of screens and objects using this framework already with no problems (they dont have a % in their mask though)
I look forward to bright ideas.
Cheers,
- ding

This behavior is documented in the API of DecimalFormat. If you don't want the special character to be interpreted, you need to quote it:
Many characters in a pattern are taken literally; they are matched during parsing and output unchanged during formatting. Special characters, on the other hand, stand for other characters, strings, or classes of characters. They must be quoted, unless noted otherwise, if they are to appear in the prefix or suffix as literals. and
'      Prefix or suffix      No      Used to quote special characters in a prefix or suffix, for example, "'#'#" formats 123 to "#123". To create a single quote itself, use two in a row: "# o''clock". see also: http://download.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html

Similar Messages

  • How do I turn off the Ipod Charging Tone?

    Firstly please don't say by turning down the sound slider because if I do I can't play the music on my ipod whilst it's charging.
    Right the situation is that my iPod touch is connected via usb in my car so I can play music on the move, also as a bonus my iPod is charging at the same time, but here's the problem because it is charging not only do I get the music from the iPod I also get the annoying charging tone through the speakers. I can't find a setting for this specific tone in the settings, and searches would suggest that it can't be turned off. I do hope this is not the case becasue if it is it's madness. Also if I connect via aux cable if the usb is connecting ie the iPod is charging I still get the charging tone trilling it's merry way.
    How can I turn off this tone. I know I can disconnect the usb ie stop the charging but that defeats to object as I then gradually use up the power meaning on long journeys I have to either dispense with the iPod or put up with the tone. Also when I get to my destination instead of having a fully charged iPod I am already down on power.
    HELP?

    Okay, well I'm still not aware of any iPod which repeats the charging tone. Have you checked in the Connector recess of your iPod to make sure there is no muck in there, or that there is no damage to the connector pins? This is because I still think that the connection between the cable, dock or whatever and the iPod is not staying "made". In other words, the connection is disconnecting and reconnecting and every time it reconnects, the beep sounds.
    Can you watch the iPod's display? When charging, the battery symbol shows the lightning bolt or, when full, the plug in the battery. Does that change to the battery only just before the charging beep? If so, that suggests that the connection is being repeatedly broken and re-made. Also check the cable (just in case).
    If you cannot solve this I think there are two options available to you.
    Ask any of your friends (who have an iPod Touch with the same iOS version on it) if their iPod does the same as yours; if they are aware of a setting for this and if so, how to turn it off, or; 
    Make an appointment at the Genius bar of your local Apple store and see if they can sort this out.
    Like you, I do not see the "change with buttons" option mentioned by kartabyaa, although I only have iOS 4.2.1 on my Touch. (I don't believe the iOS version is different to mine in this respect, but if you ask someone with the same iOS version as you, that should help confirm or refute what the iPod can and should do.)
    <Link Edited by Host>

  • How can I turn off genius in iTunes 10.5.3 (3)

    How can I turn off Genius in iTunes 10.5.3  under Lion 10.7.3 (other than disconnecting from the internet). It is no longer an option in the Store menu and although I can hide that playlist on the left through parental controls, the atom symbol is still present in the lower right of the window available to generate a list from a selected song. Thank you.

    I have the option to turn it off. What version of iTunes are you using? I have the latest iTunes. Have you tried signing out of the store?

  • How do I turn off location services on the iPhone 6?

    How do I turn off location services on the iPhone 6?
    Yes I already went to Settings > Privacy > Location Services, is not allowing me to turn it off.
    And yes I have disable the restrictions too.

    When I tapped the screen, there was a symbol on the left that looked like arrows going in a circle and on the right were the arrows crossed. The crossed arrows were orange, when I tapped this orange symbol, it turned to white and the songs STOPPED shuffle.

  • When playing back stills, how do I turn off the G..D...n zoom?

    When playing back stills in imovie, how do I turn off the G..D...n zoom? I just want it to show stills, STILL, zoom-effects do not go well with a serie of meditative fotos of sculptures.... thank you. Anyone?

    Hi
    It's called Ken-Burns effect.
    Click on one photo in Project.
    Then You see a small cogg wheel like symbol
    - click on it and a menu opens where at bottom You can
    - select Crop/Ken-Burns/Rotation - select it
    Now in Viewer/Canvas at top set Size (Adjusted) from Adjust/Crop/Ken Burns menu - now the picture will show in full and no zoom.
    As You see - there is a linguistic barrier when not having an English version of iM.
    Yours Bengt W

  • TS3988 How do I turn off iCloud and go back to the way I had it before?

    I am unhappy with iCloud for a number of reasons. I want to go back to backing up my music to an external HD, storing music on my devices, and turn off iCloud.
    How do I turn off iCloud? I have iTunes on a PC.
    THANKS

    Current Firefox versions remember the download directory based upon the URL, so if the URL changes then the default folder may be chosen if there hasn't been selected a download folder before for that server.
    *[[/questions/889958]]
    *[[/questions/882443]]
    Bug 536503 - Last downloaded-to directory should be remembered on a site-by-site basis
    Firefox 11 will have a workaround by providing a pref (browser.download.lastDir.savePerSite) to disable this feature.

  • Every time I start iTunes I get the message: "iTunes exec has been set to run in compatability mode for an older version of Windows. Turn off compatability mode for iTunes before you open it." How do I turn off the compatability mode?

    Every time I start iTunes I get the message: "iTunes exec has been set to run in compatability mode for an older version of Windows. Turn off compatability mode for iTunes before you open it." How do I turn off the compatability mode? Particularly when I have to do it before I turn on iTunes.

    Try the following document, only be sure that none of the boxes in the compatibility mode tab are checked (not just the compatibility mode box itself):
    iTunes for Windows: How to turn off Compatibility Mode

  • How will you turn off an IPhone 4S voice over with the latest IOS

    How will you turn off Voice Over in Iphone 4S? i tried turning it off through settings/accessability/voice over but when i turned it off it always go back to ON. It is very depressing to go over with this feature. Thanks.

    on your phone go to settings - icloud - find my iphone - off

  • How do I turn off the feature that allows the duplication of App downloads to more than one phone? As in my wife downloads an app and I get a dulpicate download on my phone.

    How do I turn off the feature that allows the duplication of App downloads to more than one phone? As in my wife downloads an app and I get a dulpicate download on my phone.

    To disable that feature it will depend on whether or not you sync everything in the cloud using Apple's iCloud, OR if you both use the same desktop/laptop computer with iTunes. Here is a link to the Apple support page in regards to the automatic download feature included with your iPhone and corresponding softwares such as iTunes.
    http://support.apple.com/kb/ht4539
    Follow those instructions and it will all be taken care of.

  • How do I turn off computer monitor when watching DVD movie on TV monitor?

    I think this is really a Leopard question because it involves setting up 2 monitors in System Preferences within OSX. 1) I have a wide screen TV connected to my iMac (Intel White Late 2006) through the Mini-DVI port and a separate audio cable. This connection works fine. 2) The purpose of the TV screen is only to watch DVDs using the DVD player and iDVD in my iMac. 3) In System Preferences->Displays->Arrangement, both my computer monitor and the TV screen appear as separate monitors. I have the setting to mirror each other. With this setting, the DVD movie plays on both the iMac computer screen and on the TV screen. 4) FINALLY, MY QUESTION: When watching a DVD on the TV screen, I would like to turn off the monitor in my iMac so that the screen is dark (in sleep mode to save power, etc.); I want only the TV screen to display the movie. How do I turn off only the iMac screen? Thank you. Dale

    Dale H. Eckerman Jr wrote:
    I think this is really a Leopard question because it involves setting up 2 monitors in System Preferences within OSX. 1) I have a wide screen TV connected to my iMac (Intel White Late 2006) through the Mini-DVI port and a separate audio cable. This connection works fine. 2) The purpose of the TV screen is only to watch DVDs using the DVD player and iDVD in my iMac. 3) In System Preferences->Displays->Arrangement, both my computer monitor and the TV screen appear as separate monitors. I have the setting to mirror each other. With this setting, the DVD movie plays on both the iMac computer screen and on the TV screen. 4) FINALLY, MY QUESTION: When watching a DVD on the TV screen, I would like to turn off the monitor in my iMac so that the screen is dark (in sleep mode to save power, etc.); I want only the TV screen to display the movie. How do I turn off only the iMac screen?
    That's impossible. It can only be done on a laptop but not on an iMac.

  • I was trying to make a new screen recording using quicktimeplay, but when I watched the video after recording it all I could hear was me talking while the video was showing on the screen. How do I turn off that recording and turn the right one on? thanks

    I was trying to make a new screen recording using quicktimeplay, but when I watched the video after recording it all I could hear was me talking while the video was showing on the screen. How do I turn off that recording and turn the right one on? thanks

    Hi j2399123,
    It sounds like your screen recording is doing what it was designed to do, capture what is happening on your screen, with optional voice over with the microphone.
    Screen recording is for recording what you see on the screen, it is not a "video capture" option, like for capturing a movie with sound that is playing on your screen.
    For the QuickTime recording options, check out "Recording with QuickTime Player" in
    Mac Basics: QuickTime Player creates, plays, edits, and shares video and audio files
    http://support.apple.com/kb/ht4024
    And for screen recording specifically, there's
    QuickTime Player 10.x: Record your computer’s screen
    http://support.apple.com/kb/PH5882
    Thank you for thinking of Apple Support Communities for your support needs.
    Nubz

  • HOW DO YOU TURN OFF "FIREFOX PREVENTED THIS PAGE FROM AUTOMATICALLY RELOADING". I did the "see Advanced - General - Accessiblity. and still having problems

    HOW DO YOU TURN OFF "FIREFOX PREVENTED THIS PAGE FROM AUTOMATICALLY RELOADING". I did perform the "see Advanced - General - Accessibility. It worked for me and my "user" site (don't know how to say my site) and still having problems with my wife's. I have gone to OPTIONS → GONE TO → ADVANCE and CLICKED THE LINE → ""Warn me when websites try to redirect or reload the page…""
    This did not rememdy the problem. I did try to get on the other site suggested
    http://kb.mozillazine.org/Accessibility.blockautorefresh
    but got a 404 error...
    I have googled the "ff prevented...." and after a number of hours searching I still have not found a fix...
    REALLY HOPE SOMEONE CAN HELP ME....
    JM

    You should still disable this setting:
    *Firefox > Options/Preferences > Advanced > General : Accessibility : [ ] "Warn me when web sites try to redirect or reload the page"
    The setting in "Options > Advanced > General" is meant as an accessibility feature, as you can see by the label of that section, so that people with disabilities or people who use screen readers do not get confused and is not meant as a safety protection to stop redirecting.
    What is the value of the <b>accessibility.blockautorefresh</b> pref on the <b>about:config</b> page?
    *http://kb.mozillazine.org/accessibility.blockautorefresh
    If you have problems with preferences, see:
    *http://kb.mozillazine.org/Preferences_not_saved
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem.
    *Switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance
    *Do NOT click the Reset button on the Safe Mode start window
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How do I turn off messages on my iMac after upgrading to Yosemite?

    How do I turn off messages on my iMac after upgrading to Yosemite?

    Hi,
    Open the Messages app.
    Go to the Preferences item in the app's Menu.
    Select the account pane in the Preferences.
    Each active account should have a tick in the Enable this Account box.
    This can be unticked.
    This will stop accounts logging in but will not stop the app Launching in certain circumstances.
    First of all check the app is Quit before shutting down the computer.
    The fact the app is open even if all windows are hidden can cause the app to restart when you Start up the computer.
    Messages is a  Multiple window app and using the red button on the top left of a window only closes that window and does not Quit the app.
    Also check the System Preferences > Users and Groups > your account > Login Items tab.
    This will list items that are set to Start up when the computer does.
    I have a couple of External Drive on other computers, some Anti Virus software and the common iTunes Helper plus an old version of TextExpander that will work if I launch the Preference Pane this way.
    9:44 pm      Saturday; October 18, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • How do I turn off "your recent download with your apple id" emails? Annoyingly often and they fill up my inbox.

    How do I turn off "your recent download with your apple id" emails? Annoyingly often and they fill up my inbox.  Is there a way to unsubscribe from these?

    It is in Settings>iTunes & App Stores to change automatic downloads. But it isn't your device that needs to be changed if you are the one that made the download. He needs to turn off the setting for automatic downloads on his phone. I'm guessing here, but you are all sharing the same Apple ID?

  • How do I turn off email notifications on iPad air

    How do I turn off visual notifications in email on iPad air?

    Turn off notifications (tap to enlarge image)

Maybe you are looking for

  • Error in the worklist control[[WLI-Worklist:493028]Internal error: unexpect

    Hi, The exception bellow is being raised when I call the getTaskInfos from a worklist control. Caused by: com.bea.control.ControlException: Error in the worklist control[[WLI-Worklist:493028]Internal error: unexpected ejb exception.]      at com.bea.

  • Error when create purchase order

    Hi all, I have a strange error when create po. it is display : Please enter item number greater than 0.that only a vendor and a material.I check the vendor and the material is same as other vendor and materials.if i first input the vendor and input t

  • File Upload and download without asking/specifing the path

    Hi, I have a requirement in which user must be able to edit the Abode offline form by clicking on edit link. On clicking the link document must open (either download to some temporary location) in new window and user must be able to edit & to save th

  • Converting input date alternative format

    Hi, I'm developing a screen form (not SQL Plus) in which I want the user to enter a date in any format and then convert it to another - for example, User inputs - 02/03/2000 Form converts field from 02/03/2000 to 02-MAR-2000. How do I do this ? John

  • CS4 First Quadrant CS5 Fourth Quadrant???

    I just installed my upgrade to Illustrator CS5 and have quickly noticed the quadrant change from previous versions. I need the y-axis to be positive, not negative...is there any way to change this? Unfortunately I have a feeling that I won't get the