JOptionPane Class is present in javax.swing package. This class is used to display simple dialog boxes to get the text input From the user. showInputDialog method is a static method of JOptionPane class. This method uses single parameter that specifies the prompting message that is displayed in the dialog box. In this program message is- “Enter the Number for Right Angle Trangle Height?” This method returns string value. Syntax- public static String showInputDialog (String s).
Here is the Java Example for JOptionPane.showInputDialog:
import javax.swing.*;
public class JOptionPaneExample
{
public static void main(String[] args)
{
System.out.println("Print Right Angle Trangle");
String Number = JOptionPane.showInputDialog("Enter the Number for Right Angle Trangle Height?");
int n = Integer.parseInt(Number);
int c = 1;
for(int i=0;i<n;i++)
{
c++;
for(int j=1; j<c; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}