Search code examples
javaswinguser-interfacejoptionpane

Getting text from a dialog box?


I'm trying to get a value from a pop-up that my program creates. It goes like this:

private void btnCheckoutActionPerformed(java.awt.event.ActionEvent evt) {                                            


    do
        JOptionPane.showInputDialog("Enter item price","");
        itemPrice = Double.parseDouble() 

    while();

So how do I get text from the input dialog?


Solution

  • try this

    private void btnCheckoutActionPerformed(java.awt.event.ActionEvent evt) {                                            
    
    do
        String value = JOptionPane.showInputDialog("Enter item price","");
        itemPrice = Double.parseDouble(value) 
    
    while();
    
    }