/*
 * GUI Electric Bill Program
 */
package guielectricbill;

//import the package to do GUI input/output
import javax.swing.*;

public class GUIElectricBill {

public static void main(String[] args) {
       // declare variable to store user input
        String accountNumber, customerName, address; 
        int KWH;
        double amountDue;

        // Welcome customer to the Electric Bill Calculation Program
        JOptionPane.showMessageDialog(null, "Welcome to the Electric Bill Calculation Program!", 
                "Welcome", JOptionPane.INFORMATION_MESSAGE);

        //Ask the customer for their account number
        accountNumber = JOptionPane.showInputDialog("Please enter your account number and press OK:");

        //Ask the customer for their name
        customerName = JOptionPane.showInputDialog("Please enter your name and press OK:");

        //Ask the customer for their address
        address = JOptionPane.showInputDialog("Please enter your address "
                + "(street, city, state and zip) and press OK:");

        //Ask the customer for their KWH usuage
        KWH = JOptionPane.showInputDialog("Please enter the KWH used and press OK:");

        // Calculate amount due
        amountDue = KWH * 0.0624;

        // Display the customers bill 
        JOptionPane.showMessageDialog(null, "Account Number: " + accountNumber + "/n"
                + "Name: "+ customerName + "/n" + "Address: " + address + "/n" 
                + "KWH Used: " + KWH + "/n" + "Amount Due: " + amountDue, "Your Bill", 
                JOptionPane.INFORMATION_MESSAGE);

        // Thank customer for using program        
        JOptionPane.showMessageDialog(null, "Thank you for using the Electric Bill Calculation!", 
                "Good Bye", JOptionPane.INFORMATION_MESSAGE);

        // Use System.exit(0); statement when only working with GUIs
        // It causes Java to properly terminate your program
        System.exit(0);


    }
}   

7701c78c86f398ac5d697db08ef39f7d

I have included a picture of what kind of dialog box I want to achieve, but I don't know how to go about it.
Many thanks in advance.

JOptionPane (which you have already used) also has a showInputDialog method that does exactly what you asked for.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.