Prompting the user to enter a valid value in an applet

hi everyone!
i have this code and i want to prompt the user to set a value<1000.
this doesnt work.if i enter a value <1000 the input dialog appears again.
whats wrong?
public void init()
   String j = JOptionPane.showInputDialog(null, "Enter a number less than 1000 but greater than 0");
   int i = Integer.parseInt(j);
   while(i>1000||i<1)
      String k = JOptionPane.showInputDialog(null, "Enter a number less than 1000 but greater than 0");
      int y = Integer.parseInt(k);
....code executed while i<1000 or i>0

Your while is looping on i, but inside you're setting
y not i. This should work:
do {
String k = get input from option pane
int i = Integer.parseInt(k);
} while (i > 1000 || i < 1);
In BinaryDigit's code, you won't have access to "i" after the loop. Declare it outside the loop (as you had it).
int i = 0;
do {
String k = get input from option pane
i = Integer.parseInt(k);
} while (i > 1000 || i < 1);

Similar Messages

  • How to restrict the user to enter only numeric values in a input field

    How to restrict the user to enter only numeric values in a input field.
    For example,
    i have an input field in that i would like to enter
    only numeric values. no special characters,alphabets .
    reply ASAP

    Hi Venuthurupalli,
    As valery has said once you select the value to be of type integer,once you perform an action it will be validated and error message that non numeric characters are there will be shown. If you want to set additional constraints like max value, min value etc you can use simple types for it.
    On the project structure on left hand side under local dictionary ->datatypes->simple types create a simple type of type integer
    The attribute which you are binding to value property ;make its type as simple type which you made
    Hope this helps you
    Regards
    Rohit

  • Prompting the user to enter Parmeters

    I am trying to create a parameter code that prompts the user to ask for input dates between Date1 and Date2 my code is below. How can I correct this ?
    WHERE
    ( OI_ADJUSTMENT_DTL_PAYMENT.RESP_GUAR_NBR=OI_ADJUSTMENT_HDR_PAYMENT.RESP_GUAR_NBR
    and OI_ADJUSTMENT_DTL_PAYMENT.SUPP_PAT_NBR=OI_ADJUSTMENT_HDR_PAYMENT.SUPP_PAT_NBR
    and OI_ADJUSTMENT_DTL_PAYMENT.ADJ_HDR_ID=OI_ADJUSTMENT_HDR_PAYMENT.ADJ_HDR_ID
    and OI_ADJUSTMENT_DTL_PAYMENT.AR_PROC_SET=OI_ADJUSTMENT_HDR_PAYMENT.AR_PROC_SET)
    AND OI_REVERSAL_PAY_ADJUSTMENT.REVERSAL_DT BETWEEN @variable('Enter Begin Date MM/DD/CCYY')
    AND @variable('Enter End Date MM/DD/CCYY')
    AND OI_ADJUSTMENT_DTL_PAYMENT.TABLE_TYPE = 'C'
    Thanks!

    If you are simply running SQL statements in the worksheet (ie F9), you can use either substitution variables or binds as follows:
    Substitution variables:
    REVERSAL_DT BETWEEN to_date('&begin_date', 'MM/DD/YYYY') and to_date('&end_date', 'MM/DD/YYYY')
    Binds:
    REVERSAL_DT BETWEEN to_date(:begin_date, 'MM/DD/YYYY') and to_date(:end_date, 'MM/DD/YYYY')
    If you are running your statements as a script (ie F5), you can use substitution variables as follows:
    accept begin_date char prompt 'Enter Begin Date [MM/DD/YYYY]:'
    accept end_date char prompt 'Enter End Date [MM/DD/YYYY]:'
    select ...
    from ...
    where ...
    and REVERSAL_DT BETWEEN to_date('&begin_date', 'MM/DD/YYYY') and to_date('&end_date', 'MM/DD/YYYY')
    You can use bind variables when running as a script (F5), but you need to use substitution variables to prompt the user for values, so for your case, there wouldn't be a benefit for using bind variables with F5.
    Note that substitution variables are not character values, but rather part of the statement, which is you you need to put the quotes around them when simply using them for character values. Binds on the other hand are treated as character values and we don't need the quotes when using binds.
    theFurryOne

  • How to "force" user to enter a valid value in a TextBox

    How can one create a TextBox in which the user is not able to leave (commit the value, change focus, or perform the action of another control) unless a valid value (the value to be committed) is displayed?
    The following is the best I've come up with so far.
    Good: It doesn't permit a value to be committed unless it is valid.
    Good: It doesn't permit the focus to be changed when TAB is pressed unless it is valid.
    Bad: It permits the user to perform the action associated with a button at any time.
    In the following code pressing on the button prints "I've been pushed", no matter the value of the TextBoxes. Can I stop this (in general, not for specific buttons)?
    class ValidTextBox extends TextBox {
      public-init var validValue:String = "";
      function isValid():Boolean {
        return (rawText == validValue);
      var isFocused = bind focused on replace {
        if (not focused and not isValid()) {
          requestFocus();
      override function commit():Void {
        if (isValid()) { super.commit(); }
        else {};
    var string1:String = "" on replace { println ("String1 = '{string1}'") };
    var string2:String = "" on replace { println ("String2 = '{string2}'") };
    def textbox1 = ValidTextBox { text: bind string1 with inverse; promptText: "String1: enter abc"; columns: 20; validValue: "abc"; }
    def textbox2 = ValidTextBox { text: bind string2 with inverse; promptText: "String2: enter def"; columns: 20; validValue: "def"; }
    def aButton = Button {
      text: "Push me";
      action: function():Void { println("I've been pushed!"); }
    Stage {
      scene: Scene {
        width: 250
        height: 300
        content: [ VBox { spacing: 10; content: [ textbox1, textbox2, aButton ] } ]
    }

    It sounds like you are looking for a concept of validation that groups items together. In days long gone Oracle used to have a product called Oracle Forms - that had field validation, record validation and block validation. So in your example if string1 and string2 were in the same persistable data object then the equivalent concept would be 'record validation'. The code in your button would say "if the record is valid print". A record is only valid if all its fields are valid.
    JavaFX really provides a 'GUI toolkit'. I think you are looking for a fairly advanced binding framework - a framework that builds on the concept of field level validation. You can approximate such a thing by creating a 'validation group' class. This class would be able to have nodes added to it and have an 'isValid()' function which only returns true if all the node items are valid.

  • How do I prompt a user to enter numeric data while a vi is running?

    I am writing a Labview vi that to calibrate angle sensors. I need to prompt the user to enter numeric or string data for the low and high angle points so the vi can then calculate the span based on these values and the a/d output differences at these two points. I can't use preset points because the angle data is resolute to 0.1 degrees, and having the user raise or lower a boom to a predefined point is not within reasonable expectation. I would be much obliged for any help that is offered.

    Build a subVI that has two numeric controls for the user to input the data (name them something appropriate like "High Angle" and "Low Angle").
    Add and "Enter" button to the front panel.
    Set the subVI preferences to include Open Front Panel When Called and Close Afterwards if Originally Closed. these are in Windows Appearance, Customize.
    Put a delay (say 50 ms) and a while loop on the block diagram to wait until someone presses the button.
    Connect your front panel controls to outputs on the connector pane.
    This will pop up a dialog type of window when you need the user to input data. And make the dialog window disappear when done. You can also add valid data checking to the subVI and whatever else you need.
    Rob

  • FV50-- Editing Option Error "Enter a valid value" Message 00002

    Hello FI experts,
    An user is trying to execute a tcode FV50 and clicking "Editing Options" to make changes to "Doc.Type option" from "Document type hidden" to "Enter with short name" under " Special functions for single screen transactions" section.
    When the user clicks SAVE button in "Accounting Editing options" screen, user is getting the the error message  "Enter a valid value".
    Can anyone tell me how to change this option and resolve this error?
    There are users they are successfully able to change it and I am even able to change the document type options without encountering this error.
    Any help on this is much appreciated!
    Thanks,
    Himadama

    Dianne,
    Thank you for your prompt response.
    The user has done modifications in FB00 but issue is still there.
    Could you elaborate more on what has to be done in this FB00 tcode?
    Thanks much.
    Thanks,
    Himadama

  • How to force the user to enter a value in the prompt

    Is there a way to force the user to enter a value in the prompt before they run the report?
    We have a customer specific dashbaord. The user has to enter a customer number in Dashbaord prompt on a first page of the dashboard. We store that value in a presentation variable. That presenatation variable value is being referenced in all the other pages of the dashabord. If the user does not enter a values in the first page and directly navigates to the other pages on the dashbaord, the reports on the other pages start to run for all the customers. Is there a way to force the customer to enter a value in the prompt before running any of the reports on the dashboard?
    Thanks!

    by Answer prompts, do you mean Column prompt?
    I can not use Column prompt in this senario as the user should not have to enter the same customer number over and over again when he navigates from one page to another on the same dashboards. If there is a way to default the column prompts then this would be an acceptable solution.
    I have already defaulted the prompt to a value as suggested in hte blog, but the issues occurs when the user erases the defaulted value. Is there are way to set the default value within the report?
    Can you please explaing mroe about option 3 regarding Java Script. Also please let me know what other options there are so that I can check whether they will fit my needs.
    Thank you very much!

  • Encountering Error in webadi : "&Value is invalid. Enter a valid value for the Mapping column &Column"

    We are having a custom WebADI, containing a field (Employee Name) which is a LOV.
    The LOV has ID : Person ID, Meaning : Employee name, Description : Position Name.
    There are multiple records with same Employee name but different Person ID.
    If I select an Employee in the LOV which has multiple records (through different IDs), I am getting an error in WebADI:
    "Enter a valid EMPLOYEE_NAME.
    XX is invalid. Enter a valid value for the Mapping column EMPLOYEE_NAME"
    The Query for the LOV is correct and is returning correct records.
    Any pointers on this issue highly appreciated.

    Hi,
    The problem could be with HR security profile attached to the responsibility from where you are launching the spreadsheet. Check it once.
    Thanks.

  • Popup screen with two check box and a text area for the user to enter value

    hi,
    i have a requirement when a button is clicked a popup screen should appear with two check box and a text box where the user can enter a value.
    is there any function module which has that functionality

    Hello,
    You can create a new screen and select the screen type as <b>model dialog box</b>.This will give you a<b> pop-up screen</b> and you can call this model dialog box screen in the PAI of the screen where the button is present.(At user-command).
    <b>case ok_code.
    when 'BUTTON'.
    call screen 200 starting at 10 10.</b>
    You can design the PBO of this pop-up screen as per your needs.
    Regards,
    Beejal
    **Reward if this helps.

  • Error message - KD199 Enter a valid value when Closing the Project at CJ20N

    Hi All,
    As I am trying to close a Project at CJ20N I have faced an error "Enter a valid value for the settlement type Message no. KD199"
    I have tried to remove the settlement rules to one of its WBS element, but I could not. System shows the same message - KD1999.
    Could you pls let me know how to resolve this to close the Project.
    Thank you
    Chandu

    Hi Chandu,
    I hope you have already setlted the project, since the system will not allow you to close the project unless there is Zero balance in the project. In this case, you can live without removing the settlement rule from any of the WBS element.
    If there is any need to have this settlement rule removed, I suggest to change the settlemet profile to " Do not settle" and check once again. ( If there is any cost already posted, then repost the same to any other receiver.)
    Hope this helps,
    Srinivas Potluri

  • How to insert a dialog box which prompt the user enter the general information in the SDI application?

    Im using the SDI application to build a system and now i would like to insert a dialog box which allow the user to enter the general information about themselves and then it will be saved into a text file. How to insert the dialog box and show the dialog box at the beginning of the program.

    Hi Lee,
    The easyest way to achieve this is to declare an object of your dialog box derived class (e.g. CUserInfo, public CDialog) into the InitInstance method of the main application class.
    Depending on the behavior you want you can place the code before dispatching the commands from command line (in which case the main frame of the SDI application will not be shown), or after, in which case the UserInfo dialog box will be shown over the main application window as modal.
    The code snipped bellow can be more helpfull:
    BOOL CSDIApp::InitInstance()
    AfxEnableControlContainer();
    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    //prompt user for data
    CUserInfo dlg;
    if (dlg.DoModal() == IDOK)
    //do something here with the data
    else
    return FALSE;//i.e. quit the application if the user presses the 'Cancel' button
    // Dispatch commands specified on the command line
    if (!ProcessShellCommand(cmdInfo))
    return FALSE;
    // The one and only window has been initialized, so show and update it.
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();
    return TRUE;
    Hope this helps,
    Silvius
    Silvius Iancu

  • Enter a valid value error

    Hi,
    Can anyone pls. help us figure out the problem with the newly created business partner master records?  We get an "Enter a valid value" error message when the agent (user) tries to confirm the business partner in CIC.  The user got the same error after she created another bp master record.
    I created a third bp master record for the same customer but in another application server.  I didn't get an error so I asked the agent to use this bp master record instead of the first 2.  Unfortunately, the user got the abovementioned error again after editing the bp master record that I created in the original application server. 
    Hope you can help us.
    Thanks in advance,
    Theresa

    Perform theses steps
    - In LSMW read and convert only one entry from file
    - go to SM35 -> select your session with that one entry
    - select process , option process/foreground
    - choose process
    You will have that batch input run in the foreground, so you can see all the values entered to certain input fields and all the actions which take place in that screens. This way you should see which step excatly creates the error.
    Regards
    Marcin

  • Error in MDDataSetBW.GetCellData.Please enter a valid value for character

    Hi All,
    We have a mandotory prompt on 0FISCPER for Web I Report . The promt is present in the universe.
    The query works fine in Dev , but in Quality it shows the following error
    A database error occured. The database error text is: Error in MDDataSetBW.GetCellData.  Please enter a valid value for characteristic 0FISCPER.. (WIS 10901)
    The universe is on BW Query and the BW Query works fine.
    Can someone please help on this

    Thanks Sathish for your input.
    We have created report level prompts and facing this issue because  we were selecting multiple values for prompts.
    Its working fine for single selection. Is there any way to  enable multi selection for the particular object at the BW end ?
    Or else we have to create the prompts (Single selection) at the universe level.
    Regards,
    Pranay

  • Error in VA01: Message 00002 'Enter a valid value'

    Hello Experts! When I try creating a sales order in VA01 after entering the order type and other mandatory information, I get the error message (no. 002 of class 00) saying 'Enter a valid value'. When I searched other threads in SCN with the same message, I found that this is probably because of authorizations or incorrect values in user parameters. I executed SU53 immediately after the message was issued and found that the check was successful. I even checked the profile parameters for my user ID and everything seems perfect. In fact, I was able to create sales orders until two days earlier and no user settings were changed since then. I tried creating orders from other user IDs and the same message is issued.

    after entering the order type and other mandatory
        information,  I get the error message
    If possible, share here after entering which mandatory field, system was throwing this pop up error.
    G. Lakshmipathi

  • Suggestion on using the variable index used in prompting the user

    import java.util.*;
    public class CaseOne {
    // main(): application entry point
    public static void main(String[] args) {
    //define necessary data structures (Step 1)
    int count = 5; // number of elements to average
    double value; // handle input
    double total = 0.0; // the running total initialized to 0
    int index =1; // the index of the number read,
    used in prompting the user//
    // index prompt - adds the index value to prompt and increments index
    Scanner stdin = new Scanner(System.in); //input stream
    // process inputs to determine input total (Step 2)
    System.out.print("Enter an integer number: ");
    value = stdin.nextInt();
    total += value;
    System.out.print("Enter an integer number: ");
    value = stdin.nextInt();
    total += value;
    System.out.print("Enter an integer number: ");
    value = stdin.nextInt();
    total += value;
    System.out.print("Enter an integer number: ");
    value = stdin.nextInt();
    total += value;
    System.out.print("Enter an integer number: ");
    value = stdin.nextInt();
    total += value;
    // compute average (Step 3)
    double average = total / count; // the target computation
    // display average (Step 4)
    System.out.println("The input average is " + average);
    } // end method main
    } // end class CaseOne

    I have a new stick so I'll give the OP a prod with it.
    If you want to do the same thing numerous times, what should you use instead of repeating your code over and over again?

Maybe you are looking for

  • White Border Around Flash in Dreamweaver

    When I insert my Flash file (.swf) into my Dreamweaver page, Dreamweaver inserts a thin white border around the flash video. I have tried several potential solutions I have seen but none of them seem to solve the problem. Looking for suggestions!

  • Page directive with UTF-8 charset??

    Hello,           I try to implement the following jsp with weblogic. It displays A???C on the           browser when the encoding is set to Unicode(UTF-8).           When I change the browser encoding to Western European, it works fine.           <ht

  • Help on calling servlet class!!!!!!!

    hi there in my jsp, i have a form as follow <form method="post" action="?"> </form> i need to call a servlet to do something when i click on the button in the form. i have created my servlet.java and stored it under the same project directory. what d

  • Back to My Mac - Screen Sharing Mac OS X 10.10 problem

    Sense Mac OS X 10.9 great feature Screen Sharing & Back to My Mac does not works any more. Mac OS X 10.10.1 Russian interface: We can see remote computers, but can not connect. We get a error. English interface: We can not even see remote macs. If I

  • Cannot print wirelessly os x leopard to Epson cx8400

    I have upgraded to leopard and I can no longer print wirelessly to this printer :Epson cx8400. I can print on the cx4800 at work, but not to this one at home. I CAN print usb to this printer. Help please???