UI Field showing only integers

Hi all
I need to create a field on a form that only allows the user to input whole numbers (integers).
I've implemented this as follows:
private JFormattedTextField readTimeOut;
protected void createComponents()
        NumberFormatter numberFormatter = new IntegerFormatter();
        readTimeOut = new JFormattedTextField(numberFormatter);
        readTimeOut.setHorizontalAlignment(SwingConstants.RIGHT);
}This works in the sense that it only allows integer values in the field, and along with other code, does just about everything I need.
The only problem I have is changing the number entirely. The numberFormatter will not let me delete the last character in the field.
E.g.
If the initial value is 600,000, and I delete the 6, the field shows 0. I cannot delete this zero so that the field is empty, which I need to do.
If I delete the zeros one after the other, I am left with a 6 that I can't delete.
This is not good, because to update the field from 600,000 to 12 (for example), I have to do the following:
1. Delete all the zeros, leaving the 6.
2. Enter 12, meaning the value in the field is now 612, or 126 depending on how the initial value was modified by the user.
3. Delete the 6.
I've looked at the NumberFormatter and IntegerFormatter classes and documentation but can't see anything that allows the field to contain blank values.
Is there an option to allow an IntegerFormatter to have a blank field?
If not, can anyone suggest another way of doing this?
Thanks

Kleopatra wrote:
what is IntegerFormatter, custom class? Or did you mean:
NumberFormatter numberFormatter = new NumberFormatter(NumberFormat.getIntegerInstance());    Anyway, what happens is that
- NumberFormat doesn't accept null, throws a parse exception
- JFormattedTextField doesn't accept values if the format objects
That leaves 2 locations to tackle
a) implement a custom format which does handle the null (as does SwingX NumberFormatExt)
b) subclass JFormattedTextField and manually null the value in commitEdit if the text is empty
CU
Jeanette
BTW: the Swing folks hang out in .. the Swing forum :-)
BTW2: folks here seem to like wild guessing games <g>
Edited by: Kleopatra on Apr 6, 2011 2:50 PMThanks for all the replies. I've got it working with a DocumentListener, but that loses the thousands formatting. Not a disaster, but something to consider.
Jeanette, you're right, the IntegerFormatter is a custom class that extends NumberFormatter. I didn't realise this. I'm still fairly new to Java, and am still learning using existing code in the product I'm developing.
Of the two options above, I think I prefer using a custom format. I'd assumed the IntegerFormatter class was a standard class, so hadn't thought of changing it. As that's already custom I can either change that or create my own version.
Thanks for the help.
Alex
BTW: The Swing forum is well hidden. I've only now found it because you pointed out that it existed. ;-)

Similar Messages

  • SQL Subscription field shows * only with Dynamic Text Label in SQL query

    We are using Hyperion Analyzer 7.2.x for showing budget and actual data. I have to show this financial data based on the security e.g. person in IT can see only IT dept. data. Hence I want to use dynamic text label <<userid>> for the security based on the person logging in to Analyzer.
    But when I use dynamic text label <<userid>> in the SQL query in SQL Spreadsheet, SQL Subscription field shows * only selection option. Does anyone have idea how to solve this problem?
    Thanks in advance for your help.
    -SV

    Hi
    Okay i know this is a bit crazy way.....but i think this is the solution for your issue.
    Create a report without the where clause (<<useris>>) then add a filter (sql subscription) then you can find all the values that are there in the SQL field (try to increase the query limit it is set to 250 as default) then edit the spreadsheet and add the where clause (<<userid>>).
    This will help you having the filter and the dynamic text label. I think there is an issue when you try to filter it with a where clause.
    Hope it helps.
    CK

  • Field - Show only X number of characters; Show all when double-click.

    Hi,
    I'm not too sure if this can be done.
    I can to show the content of a field for only the 1st 15 characters and if user were to double-click on it, it will then show the entire field content. Is this possible at all?
    E.g., the full content of the field is "The quick brown fox jumps over the lazy dog." The field should display "The quick brown..."
    Thanks in advance for all help/suggestion. My version of CR is CR XI R2.
    Regards.

    >
    Ashwin Jahagirdar wrote:
    > I dont think that this can be done in Crystal Reports Designer.
    Hi Ashwin,
    Thanks so much for your reply. Appreciate it.
    Anyone else have any idea? Thanks.
    Regards.

  • Display Image on report through Field Definitions Only File.

    Hi all,
    I have a report where I work with Field Definitions Only files (ttx).
    These files are mapped to classes in code behind (csharp).
    In code behind I make lists of these classes. Each list is set as the datasource of a subreport.
    This works great!
    My new goal:
    Now I tried adding a picture to my report.
    In the TTX file I added a BLOB field.
    In the code-behind class I added a System.Drawing.Image.
    My actual problem:
    The class gets filled with the image, but the image is NOT displayed on the report
    Does anyone know why this is happening?
    How can I fix this? (should I use another Type in my class for the picture?) (should I format the picture in the report? ....)
    Kind regards,
    Wim

    Hi AG,
    Thanks for your response.
    This is my TTX field:
    Signature     BLOB          
    I can't see the image in the report because I create the image in code-behind.
    I think the problem doesn't occur in CrystalReports but in the conversion from my StrokeCollection (I use an InkCanvas [WPF] to capture a signature) to a ByteArray.
    I am already one step closer to the solution. You can't just assign an object of type Image to the BLOB field of the report but it has to be a Byte-Array.
    The problem I am facing now is that the picture is black after a conversion. (I see this when I export to disk and open the file in MSPaint).
    The good thing is that CR shows me a black image so I guess CR is doing its job!
    Kind regards,
    Wim

  • TS1702 i if use "search" in music on my ipod touch 5th gen the result just show only album and playlist but nothing song result.whats wrong with it?please help

    i if use "search" in music on my ipod touch 5th gen the result just show only album and playlist but nothing song result.whats wrong with it?please help

    The users guide says:
    Spotlight searches the following:
    Contacts—All content
    Apps—Titles
    Music—Names of songs, artists, and albums, and the titles of podcasts and videos
    Podcasts—Titles
    Videos—Titles
    Audiobooks—Titles
    Notes—Text of notes
    Calendar (Events)—Event titles, invitees, locations, and notes
    Mail—To, From, and Subject fields of all accounts (the text of messages isn’t searched)
    Reminders—Titles
    Messages—Names and text of messages
    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Unsynce all music and resync
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup
    - Restore to factory settings/new iOS device.
    - Make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar

  • TEMPLATE.fmb - no fields show up

    Hi,
    I'm trying to develop a custom form but having trouble with the template.
    1. Copy template to my directory in Unix and compile.
    2. I run it through the applications but no fields show up on the template. Is this normal? I don't think it is but I haven't created a new form from the template in a couple of years.
    3. Messing around with the form I removed the sub-class and was able to get a couple of fields to display but I changed so many things I don't seem to be able to duplicate. And I really want to be able to use the standard sub-classes which still didn't work when I set the fields manually.
    Thanks for any help.
    Andy
    Additional information:
    I've also concluded that when I compile an existing form FNDSCAPP.fmb errors occur so it is not limited to the template.fmb.
    See error below, there was only one. Any ideas as to what would cause this?
    Compiling PRE-INSERT trigger on APPLICATION data block...
    No compilation errors.
    Compiling PRE-QUERY trigger on APPLICATION data block...
    Compilation error on PRE-QUERY trigger on APPLICATION data block:
    PL/SQL ERROR 49 at line 1, column 5
    bad bind variable 'parameter.g_query_find'
    PL/SQL ERROR 49 at line 1, column 5
    bad bind variable 'parameter.g_query_find'
    PL/SQL ERROR 49 at line 3, column 3
    bad bind variable 'parameter.g_query_find'
    Compiling PRE-UPDATE trigger on APPLICATION data block...
    No compilation errors.
    Message was edited by:
    Andy123

    Oracle Forms is a tool (somewhat like Visual Basic in appearance, but the code inside is PL/SQL) which allows a developer to quickly create user-interface applications which access an Oracle database in a very efficient and tightly-coupled way. It was originally developed to run server-side in character mode on any Unix box, before Windows existed. It was then ported to Windows to function in a client-server environment. Recent versions have been ported to Java. It now runs in a J2EE container and can integrate with Java and web services.

  • In service order Search page,In Service Order Search criteria, In Status value drop down i have to show only user status?

    Hi Team,
    My requirement is In service order Search page,In Service Order Search criteria, In Status value drop down i have to show only user status values only? how to do it..now in my status drop down values system status values also displayed ,i want only user status values only i have to show...how to do it?
    Thanks
    Kalpana

    Hi Kalpana
    As Standard there are 2 separate search fields for Status.
    One for User Status
    One for System Status
    Are you sure that the other Status value you require are not for other Service Transactions different to the one you are wanting to search on?
    If you need to make a only the User Status for  a given selected Transaction Type, then you would need to make an enhancement to that Component
    Regards
    Arden

  • Feature: Show ONLY IMAGES of a webpage??

    Hello...
    I recently installed some add-on Safari enhancement type things (like Safari Enhancer and SafariStand) while at the same time, checking out Firefox as well. It was LATE at night and I do NOT recall what I did but I brought up some pageview function that took the webpage I was currently viewing and opened a new page that showed ONLY THE IMAGES of the page. For example, on this page that you are currently viewing, the image-only pageview would ONLY show the Apple icon tab above and the "Store" and "iPod + iTunes" and ".Mac" tabs above as well as the Logout, My Settings, My Posts, My Subscriptions, etc icons from the page....NO text or links or fields to fill in.
    PROBLEM is that I CANNOT remember what I did to show that pageview of only images!! Actually I do not know if I did this in Safari or FIREFOX!!
    I was wondering if anyone was familiar with this image-only pageview option?? Or whether it was in Safari or Firefox and how to bring it up again??
    Thanks!!
    Scott
    Powerbook 1.67GHz AL   Mac OS X (10.4.7)   Oadedlay with ornpay...

    Select that folder in LR and run the search again. It should be restricted to the folder. I asume the original search was doen in All Photographs.
    Don
    Don Ricklin, MacBook 1.83Ghz Duo 2 Core running 10.4.9 & Win XP, Pentax *ist D
    http://donricklin.blogspot.com/

  • Dataelement of data type char but accepts only integers

    Hi Experts,
    I have a scenario where quantity field in output is editable and the user wants the quantity field printed without thousand separator. If i take a char field and display the field is editable then user may mistakenly type a,bcd...z/ special characters which it should not capture. Is there any char data type data element which accepts only integers. Because after that i need to save that value in z database table quantity field.
    Please share your suggestions.

    I have a scenario where quantity field in output is editable and the user wants the quantity field printed without thousand separator.
    I'm a bit lost with your statement, as you consider changing the data type it sounds like you have control over the program and thus most likely also over the forms (assuming that printing means sending some output to a printer). In that case I'd first consider keeping the quantity field as is and change the output logic (e.g. print program or form) so that the group (thousands) separator doesn't appear for that quantity field (and refrain from changing the field definition). (Similarly if it's just concerning the output of a field on the screen then an appropriate output mask/template for that screen field should be the right way to go.)

  • INFOPATH: Only Integers allowed validation tooltip

    I have a few lookup columns in an InfoPath library form template. The underlying fields are integer numbers, and the control is a dropdown which is populated from a secondary data connection. If the field is mandatory, a little validation tooltip reminds
    you "Only integers allowed". My users will be confused by such information. Is there a way to overwrite this message or at least switch it off? Thanks. Iko

    Any luck in solving this issue?
    Ok, this workaround helped me forward. Uncheck the option "Cannot be blank" on the drop down list. Instead, if you need validation and the field is mandatory, create a validation rule on the InfoPath control. its the same function, with a more meaningful message
    that you can customize.
    Hope it helps..

  • I want to allow only mp3 files in uploading, File dialog have to show only

    In my project , user have to upload Mp3 files.
    we want to show only mp3 files in file dialog .
    in file dialog ,filetype field contain only mp3 .
    let me help inthis.
    Regards ,
    Vyam.

    Thanking you for giving reply to my query.
    I have seen in VB and someother language is it
    possible.No you haven't.. You saw something else entirely.
    >
    Actually am trying with this is in html file element
    only , But am unable to control the file dialog
    window with selected Extension files.
    Right. You can't do what you are trying to do it's impossible. You can stick an accept attribute on your form tag and It MIGHT work. But this is browser dependent and will not neccessarily be enforced.
    Best to do what I told you before. Validate the uploaded file for type on the server.
    It is showing All files. I tried with accept ,
    enctype also , but failed.
    Then you are hosed.
    can we do with FileFilter class in java.Is it
    possible.
    How do you see this working? If you want you could build an applet that you could sign that would upload the file for you I suppose. Seems a lot of unneccessary work.
    Thanking you,
    Vyam.Welcome.

  • HtmlText fields show up blank

    Hi
    I am trying to load some dynamic text fields with html tags as follows:
    _root.pag.pages.page12.home.htmlText = "<font face=\"Verdana\" size=\"24\" color=\"#FFFFFF\"><b><a href=\"http://www.sspaintings.com\" target=\"_root.pag.pages.page1\">Home</a></b></font>";
    _root.pag.pages.page12.about.htmlText = "<font face=\"Verdana\" size=\"24\" color=\"#FFFFFF\"><b><a href=\"http://www.sspaintings.com\" target=\"_root.pag.pages.page2\">About</a></b></font>";
    I have rendered them as html and selectable in the properties area.
    When I test the movie the fields show up with nothing in them.
    I have also used the _root.pag.pages.page12.home.html=true; but it does not work either.
    The texfields contain nothing. Are these commands not good for As1 - Flash 6
    Any insight will be appreciated. Thanks. Samantha

    Hi Ned,
    Thanks so much for your insight. Your comment on labeling it text as opposed to htmlText was really good.
    After I did that it still did not show. I used labels from other pages that were working and re-routed them to that page and it still did not do it.
    I realized that I had created those text fields as a copy paste activity from Frontpage into Flash. (Not that I think it should matter) but that was the only difference when I created that page. The other thing was that the textfields were all grouped in a movie clip something I tried to undo and it did not work it would go back and regroup them into a movie clip. I also tried naming the instance of the movie clip and adding it to the path but to no avail.
    So I just deleted that page and started from scratch with a page that already had fields in it and slowly changed everything to what I needed and it worked.
    The path is the same except the textfields have been simplified. You can see it in www.sspaintings.com>about>sitemap.
    (Sorry for the delay you hear in the music, there is a movieclip loading in the background which is doing this but I haven't fiugre out why)
    _root.pag.pages.page12.tf_1.htmlText="<font face='_sans' size='11' color='#FFFFFF'><b><a href='http://www.sspaintings.com' target='_root.pag.pages.page1'>Home</a></b></font>";
    _root.pag.pages.page12.tf_2.htmlText = "<font face='_sans' size='11' color='#FFFFFF'><b><a href='http://www.sspaintings.com' target='_root.pag.pages.page2'>About</a></b></font>";
    Also as to you input on Flash/SEO, thanks, I suddenly realized again how closed flash is to search engines.
    Thanks so much again for your thoughts.
    Samantha
    PS: Can you tell me how to write the tag so that the page opens inside the window and doesn't open another window of the movie?

  • Bex Report to show only latest record on report and then history

    Hello Gurus,
    Table 1:
    Employee
    Valid From
    Valid To
    Hours Perday
    1900
    01/01/2014
    02/28/2014
    8
    1900
    03/01/2014
    03/31/2014
    6
    1900
    04/01/2014
    12/31/9999
    4
    Table 2:
    I have above in DSO, On report I need to show the latest record without Valid From and Valid To Fields shown below.
    Employee
    Hours Perday
    1900
    4
    And when user drags Valid From and Valid To field from free charac. it should show history as in DSO. I have leveraged 0VALIDTO customer exit processing variable with variable as "Value Ranges" >= Key Date so when query is executed if date entered is 04/01/2014 it should bring last record with Hours perday=4 and if date is entered as 03/01/2014 should bring two records with hours per day 6 and 4 and so on.
    The problem on report is that the record being pulled is always latest but when Valid To and Valid From free characteristics are dragged on the report it still shows the latest record and no history. Is there a way that when key date is entered it should show latest record as per >= of that key date and when Valid from is dragged in to report it should display history prior to that key date?
    Thanks,
    Sam

    Hi Sam,
    You are almost in the right direction. A little fine tuning is required in your process
    As you are dealing with Time dependent Master data, the ideal thing to use is "Key Date" in the query. But there is a limitation here. Key Date can show only single date's relevant master data. I mean if you enter 03.01.2014, only second record would be shown. Key date cannot work on Multiple dates or ranges to fetch historical data or multiple records accordingly.
    To achieve your requirement, you should not use Key date in your query.
    I have leveraged 0VALIDTO customer exit processing variable with variable as "Value Ranges" >= Key Date
    The above idea is good. You should make Valid From as Cust exit(i_Step =2) processed and make it as User Entry enabled. So that user exit code can pick up values as per > = Valid From(User Entry Based). But this user exit will be picking historical records if user enters other than latest Valid from date. I mean no drilldown is required. You need to use Valid from in rows also, I believe.
    Try this and let me know if you want any more inputs.
    Regards,
    Suman

  • Ipad with ios5 shows only 1000 emails. Would like to see all that are not deleted.

    pad with ios5 shows only 1000 emails. Would like to see all that are not deleted. iCloud turned off for Mail. Using Outlook on MacBook.

    Just a historical note of interest, Yahoo Mail was one of the first IMAP Push providers on the original iphone, so they did at one time support IMAP. My guess is you will have to get the server settings from tech support, which you are paying for.
    But the gmail app is called gmail :-) and the technology that allows you to link it to a domain is known as google apps. (www.google.com/apps).
    But I would call Yahoo tech support and ask them what the proper way to set it up on an ipad or iphone is.
    If you built your website using Yahoo tools (ie. their website builder), you may find it difficult to move.
    The appropriate place to discuss moving web hosts is here. www.webhostingtalk.com
    Site5 was able to migrate my clients' sites for free from a non-Yahoo host, although if you do want e-mail make sure you specify that in the notes field. (MX)
    www.site5.com
    --Sam

  • When I open up iphoto and click on the events tab then double click on an event, it used to show minis of all the photos in that event.  Now it shows only one photo at a time.  How do I get it back? Can you help?

    When I open up iphoto and click on the events tab then double click on an event, it used to show minis of all the photos in that event.  Now it shows only one photo at a time.  How do I get it back? Can you help?

    On the bottom bar of the window (on the left iPhoto 11, on the right in other versions) note the slider. Drag it left.
    Regards
    TD

Maybe you are looking for