Check for zero

I am looking for a way to check input fields for zero values in my action listener and bring up a message dialog if it finds one. I can get it to look for null or alpha characters but I can't figure out how to look for zero. Any suggestion would be appreciated. My action listener code is below...
public class MyActionListener1 implements ActionListener
    double newAmount;
    double newRate;
    double newTerm;
    // Tell the JButton (calcButton) what to do when clicked.
    public void actionPerformed(ActionEvent evt)
        try
            AbstractButton calcButton = (AbstractButton)evt.getSource();
            newAmount = Double.parseDouble(principleValueText.getText());
            newRate = Double.parseDouble(rateAPRText.getText());
            newTerm = Double.parseDouble(termYearsText.getText());
            pmtText.setText(nf.format(getMortgagePmt(newAmount, newTerm, newRate)));
            pmtText.setForeground(Color.red);
            principleValueText.setText(nf.format(newAmount));
            rateAPRText.setText(np.format(newRate/100));
            termYearsText.setText(ni.format(newTerm));
        // Privide error handeling to check for valid input.
        catch(NumberFormatException nfe)
            JOptionPane.showMessageDialog(null, "The value must only contain digits",
                                                      "Input Error", JOptionPane.WARNING_MESSAGE);
}

I don't quite understand your problem, but I think what you're saying is that if any of the parsed numbers are 0, you want to show a dialog box that says you can't have "0" values?
There are two ways to do this: after parsing each number, you can just simply use the block:
if(number == 0){
    JOptionPane.showMessageDialog(null,"...","...",...);
}You can call the JOptionPane methods whenever you want to in your program.
Now, another way of doing this, though kind of like over kill, you can use a block like this:
if(number == 0)
    throw new IllegalArgumentException("Number cannot be 0!");and then after your catch(NumberFormatException) block put:
catch(IllegalArgumentException iae){
    JOptionPane.showMessageDialog(null,iae.getCause(),"Error",JOptionPane.ERROR_MESSAGE);
}or something to that effect. once again, second solution is kind of overkill, but it would work (and stop the execution of the rest of the method)
If I completely understood your problem, I'm sorry =D
Alex

Similar Messages

  • No Inventory record generated for zero stock check

    Hi All,
    The issue is no inventory record created for zero stock check.
    prerequisite:
    1. I activated the zero stock  check for the storage type in warehouse,
    2. I also activate the PZ inventory method for zero stock check for this storage type.
    3. storage type is under with 'P -Storage unit type" putaway strategy.
    Steps:
    1. First time I moved the last SU out of the bin, it generated a physical inventory when creating the TO.
        we can go to the item - other data of the TO, and found that hte inventory record created with "PN" inventory method. and the zero stock check indicator is 1.
    2. Then I continued to confirmed the TO with empty bin check. the invetory record was cleared when confirmed the TO.
    3. Then I moved that SU back to the same bin.  (only has one SU in the bin)
    4. Try to create the TO to move the SU out, the TO created, and if we go to TO item - other data, the Zero stock check indicator is 1, but this time, it doesn't create any inventory record?
    Can anyone tell me why it didn't create the inventory record in the 2nd TO?
    Thanks,

    i tried to replicate the case and got the same result that only first time inventory documen was created.
    seems its standard behaviour and if the inventory is already done for the bin then it does not carry out again for the same bin automatically as it did earlier.

  • Zero stock check for a bulk storage type

    Hi Experts,
    We have a requirement to do the zero stock check for a bulk storage type. As a standard SAP it is not allowed to do the zero stock check for a bulk storage type. Is there any way to do this?
    Thanks & Regards
    Sanpan

    Hi Sanpan
    I am in a similar boat.
    We have a Bulk warehouse with storage types with 'B' putaway strategy. We would also like to instigate zero stock check but get the message Zero stock check not supported in bulk storage areas with storage units
    Message no. LT246
    Did you find a solution to this? Or have you coded a solution?
    Many thanks
    Adam.

  • Unable to view entries in FAGLL03 for Zero Balance Clearing Account

    Hi experts,
    We are facing a unique problem. We are not able to view the line items of the Zero Balance clearing account. The master data of the G/L has been activated for line items but still the display of the items is not happening. I am getting the foll message:
    Account 19900000, company code 1100 is clearing account
    Message no. MSITEM111
    Diagnosis
    You have stored account 19900000 in company code 1100 as a clearing account. At the same time, you use line item management with this account.
    System Response
    Error message issued because line item display cannot read data for an account in a ledger if line items exist partially in the entry view together with clearing items for which there are no line items. In such cases, only the data with line items would be selected.
    Procedure
    Check the Customizing settings or account control. Change the settings so that only automatic postings without line items can be made to the account, or select a different account as the clearing account.
    Regards,
    Sateesh

    Hi
    In splitting case you need not the give the line item display tab for Zero Balance Clearing Account.
    Just remove that line item display in FS00 for Zero Balance account. You could be able to see the entries in FAGLL03
    Regards
    Sandeep

  • How to prevent creation of billing docs for Zero Quantities

    Hello everyone,
    Could someone please help me with this.
    We have some invoices created with 'zero' quantities. We need to stop prining invoices for the invoices with zero quantities. Can we stop creating invoice for zero quantities. if yes , please let me know how. Any help is very much appreciated.
    many thanks
    Edited by: Simsasha on Jan 30, 2009 2:31 AM

    Dear Simsasha,
    Could you please breif whether:
    1. Its Order-related-Billing, OR
    2. Delivery-Related Billing
    If, Its Order-related-Billing, You need to work-around Copy-Control Setting in VTFA; and if,
    Its Delivery Related-Billing, You need to work-around Copy Control settings in VTFL.
    You need to write Code to check Quantity = 0, and attach the same within Field: Data VBRK/VBRP; to check and avoid Invoice creation, if Invoice-item has billed quantity as 0.
    You may work with Program RV60AFZC USEREXIT_FILL_VBRK_VBRP
    Best Regards,
    Amit
    Note: You may take help from the discussion from following thread:
    [Billing with Zero Quantity, not allowed|Re: Billing for zero quantity is being allowed]
    I hope, this would definitely help you, some extent.

  • How do I check for bad sectors on the hard drive? (Need help soon!)

    I've asked this in a different thread but am not getting exactly the question answered completely. I need to run a check on my drive that will test each sector and if a bad sector is found, it will block that sector from being written to with data in the future.
    I used to use Disk First Aid or Apple HD Setup or Norton Utilities to do this. Norton does not appear to be made for Mac OSX 10.4.4 and those other utilities appear to be System 9 and earlier utilities only.
    Is there some way of doing this with current Apple tools? My original post is at http://discussions.apple.com/thread.jspa?messageID=1592160#1592160
    Thank you. I've been down since Saturday and really need to get an answer so I can move forward and get my computer back up and running.

    There is only one way to do this. Make a bootable backup of your drive to an external Firewire drive (you can use the Restore option of Disk Utility.) Then do the following:
    1 Boot from your Tiger DVD. After the installer loads select Disk Utility from the Utilities.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Click on the Partition tab in the DU main window.
    3. Set the number of partitions from the dropdown menu (use 1 partition unless you wish to make more.) Set the format type to Mac OS Extended (Journaled, if supported.) Click on the Partition button and wait until the volume(s) mount on the Desktop.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled, if supported.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process will take 30 minutes to an hour or more depending upon the drive size.
    By reformatting using the Zero Data option DU will force checking for bad blocks.
    If you wish to forego the above procedure you can purchase TechTool Pro (v. 4.1.1) which has a module for scanning the disk for bad blocks. However, repairing the drive can only be done by reformatting.

  • PL SQL block - Check for empty file

    Hello,
    I need help in writing pl sql code to check a file to verify if it has 0 records (file size = zero kb.) In a preceding pl sql block, I am performing a SELECT on data and writing it to a file. If that file is empty/has no records, then I would like to stop the process from continuing on to my next pl sql block which performs an update function.
    Summary:
    1) Create file from SELECT
    2) Check file for zero data, if true, trigger error, if false, continue to next pl sql block.
    3) Run update on records if data exists in the file.
    Thanks in advance!

    Thanks John,
    You've been of great help so far and a really appreciate it. I'm so close to getting this, I just need help with how to create an error when the file shows no data. I will be running this as an Oracle Apps Concurrent request. I'd like for the job to end in error when no data exists for the file. In unix, I can enter "EXIT 1" and it signals to the concurrent manager to put end the job with an error status. How can I do something similar using pl sql? Here is my code so far, with the missing piece. Thanks!
    DECLARE
      vFile UTL_FILE.FILE_TYPE;
      vrecs BOOLEAN := FALSE;
      vnodata EXCEPTION;
    BEGIN
      vFile := UTL_FILE.FOPEN('/devlop, 'norecs.txt', 'w', 32767);
    FOR x IN (
    SELECT
         node_name AS txt
    FROM
         applsys.fnd_nodes
    WHERE
         node_name = 'blahblahblah'
    LOOP
            vrecs := TRUE;
            UTL_FILE.PUT_LINE (vFile, x.txt);
    END LOOP;
            UTL_FILE.FCLOSE(vFile);
            IF NOT vrecs THEN
                RAISE vnodata;
            END IF;     
    EXCEPTION
           WHEN vnodata THEN
        *<what can I put here to cause the pl sql block to error???>*
    END;
    /

  • How to disable checking for updates on Mac Silverlight for enterprise environment

    Hi Guys,
    We are trying to create a package for our enterprise environment to push the install of Silverlight for the Mac and have it not automatically check for updates.
    What is the best way to do that?
    I found the setting in the com.microsoft.silverlight.plist file that was in the user profile/library/preferences folder.
    Is there a way to have this UpdateMode key set to the desired setting regardless of which user is logged onto the mac?
    Thanks.
    Aaron

    I have zero experience of macs.
    Can't you install Silverlight and the plugin for all users rather than a specific one?
    I would guess/hope/expect there'd then be one plist file for everyone? 
    Please don't forget to upvote posts which you like and mark those which answer your question.
    My latest Technet article - Dynamic XAML

  • How to disable checking for updates for Shockwave plug-in?

    SOS: how can I disable checking for updates (and reporting
    that there is one) for a Shockwave object on a web page?
    I have a client with an older Shockwave version, and it's a
    royal pain for each user to be told there's a newer veriosn and do
    you want to download...
    Any help gratefully received.

    I have zero experience of macs.
    Can't you install Silverlight and the plugin for all users rather than a specific one?
    I would guess/hope/expect there'd then be one plist file for everyone? 
    Please don't forget to upvote posts which you like and mark those which answer your question.
    My latest Technet article - Dynamic XAML

  • Code Check for Disk Freespace

    Hello, 
    I have a very basic Powershell command string working, but when I execute it I get an error that says "Attempted to divide by zero".  When doing the math I am not attempting to divide by zero, so even though the commands work, I was wondering
    if anyone could explain to me why that error pops up. 
    Thank you!
    Get-WmiObject win32_logicaldisk | where-object {$_.Freespace -ge ((($_.freespace/$_.size) * 100)
    ) -and $_.drivetype -eq 3}

    Hello jrv, 
    Actually, the arithmetic does work.  The problem is that I was trying to filter the drivetype in the where-object instead of with the filter as you suggested.  As soon as I switched that around my where-object and my formula worked just fine. I
    don't appreciate your snide and unnecessary comment at the end about skipping class in the second grade and if I could report it as abuse I would.  I am trying to learn powershell as a beginner and people like you make asking questions difficult. 
    How about you try helping others instead of putting them down?
    As I poited out - elementarty school arithmetic.  The math does NOT work in any kind of usefule fashion.
    Look closely at the numbers and you will see what I mean.
    (($_.freespace/$_.size) * 100)
    This is always 100 time the freespace reading,  T^hat makes "Fre4esapce equal to 1/100 of this number or 1%.
    $_.Freespace -ge ((($_.freespace/$_.size) * 10o
    if freespace is 10 and size is 100 then the numerbs are (10 -ge  ((10/100) * 100)
    Factor out10.
    (1 -ge  ((1/10) * 10)
    1/10 * 10 will always be 1.
    You are in eff3ect saying is 1 greater than or equal to 1 which will always be true.
    The test is pointless and does not check for a freespace threshold.
    We want here to see the percentage of free space.  Percentage is a ration of two numbers.
    Freespace/Size is a ration (third grade arithmetic - if I have three cookies and I give one to you what fr4action did I keep?
    if freespace ia1 25 GB and Size is 250Gb then the ratio p(unnormalized percentage) is 23/250 or 1/10 or .10000000 TO kae this a human percentage with a % sign we multiply by 100. .1 * 100 is .... 10 and then add the sign for 10&.
    The frespace (%) for a dis is (freesapce/size) * 100 if expressed as a percent.
    ?{($_.freespace/$_.size * 100 -lt 10}
    This would filter out and show all drive that have less than 10% freespace.
    It is easier to just say this:
    ?{($_.freespace/$_.size -lt .1}
    Since the ratio will alwys be a number less than '1'.
    Too many techs including many with college degrees get this wrong because they forgot what they learned bout apples and pies in elementary school.
    Don't feel bad. You are in good company.  Most of Congress cannot add or do ratios either.
    ¯\_(ツ)_/¯

  • Billing for zero quantity is being allowed

    Hi,
    We have written a new copy control routine for data transfer VBRK/VBRP from Sales Documents to Billing Documents. This routine is for partial billing. When the partially billed quantity becomes zero, the transaction vf01 still allows the billing. But we should not allow billing for zero quantity.
    In the copy requirements routine, it does gives out error message if the quantity is zero. But this copy requirements routine is being called prior to our data transfer routine. So if the quantity becomes zero in our partial billing routine, the transaction vf01 is not giving any error message and it is allowing the billing for zero quantity.
    Could anyone please let me know how can I solve this problem or what are the ways to solve this problem?
    Thanks..
    Priya.

    Hi Naren,
    The checking part is already there in the standard copying requirements routine, which we are using. There can be many scenarios when the quantity will  be more than zero when the copying requirements routine is called and it can become zero only in our data transfer routine logic. The copying requirement routine is being called prior to the data transfer routine, so in the above case, the copying req routine will not add the error message since the qty is more than zero, but it will become zero in our data transfer routine. So the invoice will be created for zero quantity also. Please let me know if there is any other ways to achieve this..
    Thanks again..
    Priya.

  • Checking for duplicate primary keys on row inserts

    Checking for duplicate primary keys on row inserts
    I have a situation where I will be making bulk table inserts knowing that the primary key value will in some cases already exist. In this is the case I simply want to ignore the duplicate inserts.
    Should I be performing a sub-query on the table and using a statement like:
    where not exist in
    Or is there a cleaner way of discarding or checking for duplicates on insert.
    My concerns were mainly one of performance, as my routine will be inserting a few thousand rows in its operation.

    The MERGE commnad is a good option when a large percentage of the data will exist in the target because it is much more efficient to attempt to update then insert when the update affects zero rows than capture an error and convert it to an update.
    However, since in this case it would appear that only a few rows will alreadys exist and we want to ignore the duplicates when they exist then
    begin
    insert
    exception
    when dup_value_in_index then null;
    end
    would be the way to code this one. The bulk insert version has in 9.2 the ability to store the errors so that they can all be handled at once which means the rest of the array insert can work.
    HTH -- Mark D Powell --

  • Starting ColdFusion server: error, no known vms (check for currupt jvm.cfg file)

    just installed ColdFusion, from adode flex 3 training from the sourse. But when I check to see if it works correctly by entering jrun -start cfusion in the command prom I get the error, no known vms (check for currupt jvm.cfg file). I tried uninstalling Java and reinstalling but nothing changed.
    I don't know what I need to do to get it working can anyone help?
    many thanks

    When you say you can't open the jvm.config file, what exactly does this mean? Is the file zero-length? How have you tried to open it? It's a text file, and should be opened in Notepad.
    Dave Watts, CTO, Fig Leaf Software
    http://www.figleaf.com/
    http://training.figleaf.com/
    Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
    GSA Schedule, and provides the highest caliber vendor-authorized
    instruction at our training centers, online, or onsite.
    Read this before you post:
    http://forums.adobe.com/thread/607238

  • Health check for load balancing ALSB/OSB instances

    What is the standard practice for a load balancer sitting in front of ALSB/OSB instances as far as a health check? I'm working with our IS department to implement a valid health check. Currently the load balancer (older model cisco device) is just checking for an active port which is generating excessive logging on the ALSB side. As a workaround I'm just going to have the loadbalancer check for a http 200 response and a greater than zero body size.
    thanks in advance...

    it depends on the type of load balancer what it can do. I suggest create a 'empty' proxy service that does not have logging or auditing. Publish the prox and use this webservice in your load balancer to check if the service is available.
    Marc

  • ATP check for component materials

    Hello experts,
    The ATP check was initially designed for a kitting process. BOM Material would be kitted in the distribution center(DC) and sent to a garage. Sales orders are created with BOM materials for a garage and there is a multi- level GATP process in place. Since BOM materials do not  exist at a garage the check would be performed at a DC for components after BOM explosion. The existing configurations in R3 and APO are for a make to order process(Strategy  group of 50 for BOM's  and 40 for component).
    We are now introducing new materials for an existing material and have the need for product substitution on the sales order, if the existing material is out of stock at the DC. To enable this functionality we are having to perform an ATP check for the sales orders at the distribution center, though the sales order is   created for a garage. To improve on the response times during the ATP check our design approach, is to convert the BOM materials in the sales order to component  materials with material determination(one BOM material is tied to one component material) and performing the ATP check with components at the DC.
    While testing we are facing the following issues:
    1)Sales order placed on a garage is substituted with the DC after product substitution.  This does not occur when product substitution is carried out with BOM's.
    2)During the order create, the ATP checks for check mode u201845u2019 and business event u2018AEu2019 for a given material in a DC shows zero stock. While for the same material,location and business event AE the product availability check in APO reflects stocks available.
    Is it feasible to do ATP checks for component material in a sales order which was initially designed to work with BOM materials? Am I missing some configuration settings in either APO or R3?
    Regards,
    Anil DeSouza

    Hi Anil,
         Yes it can be done.
    1) For finished product & garage combination -
    activate RBATP in the check instructions.
    2) in the location substitution maintain 'location determination sctivity'. Here you maintain different check mode & business event -- ( this is nothing but check instruction --- in thsi you maintain 'MATP').
    Hope this anws your first qus.
    To addressing your 2nd question....follow below steps.
    1) Do ATP from sales order, get onto results screen, click on product availability & check for 'scope of check' (check control) and look for the stock types that are included. Based on this your receipts are consdiered for ATP confirmation.
    Best Regards,
    Deepthi

Maybe you are looking for

  • HT1918 can i have two different itunes accounts on one computrer

    can i have two itunes accounts one for my wife as she keeps getting my contacts on her phone and shes not happy!!!!!

  • Audio Causing Multicam Crashes - AudioRenderContextConstructor.ccp-110

    Hello - I do a lot of multicam interview edits and am running into a relatively consistent crash inducing scenario, namely, editing a multicam group with any audio inserts applied causes premiere to crash. The official error is related to AudioRender

  • MacBook Pro settings to hear XM Satellite Radio

    XM Radio came in loud and clear when I first received my MacBook Pro using wireless. Now I open XM but no sound. I get sound on other sites. Any specific settings required? XM tech support suggests opening ports 80 (HTTP) or 1755 (UDP, TCP). Does Mac

  • CS3 to Creative Cloud

    If I choose the special offer (https://creativecloud-specialoffer.adobe.com/special-offer/?loc=en_GB&cc=ie), can I still use my CS3 package in future or does it work like an upgrade and my CS3 will be deactivated? Thanks, Viktor

  • "Sync Contacts" option missing from Google Account Sync

    Yes thanks, I've tried all options I can find... which are :- Sync Now- Remove Account Nothing else. I've tried deleting the account and adding it back. Still no success.  R