by Dinesh Thakur Category: Swing

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();
                  }
         }
}

JOptionPane.showInputDialog



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles