I am looking for QTP containing inputbox kind of method in java

114 Views Asked by At

I am new to the java,I have experience in QTP. In the QTP we have inputbox built-in function. so at runtime while developing program we can give input value using inputbox function. So, I am looking for similar method in the java.Can you please help me any built in method is available in the java?

Thanks in advance for your help.

2

There are 2 best solutions below

0
On BEST ANSWER

You may use Java scanner class here as below:

import java.util.Scanner;

class GetInputFromUser
{
   public static void main(String args[])
   {
      int a;
      float b;
      String s;

      Scanner in = new Scanner(System.in);

      System.out.println("Enter a string");
      s = in.nextLine();
      System.out.println("You entered string "+s);

      System.out.println("Enter an integer");
      a = in.nextInt();
      System.out.println("You entered integer "+a);

      System.out.println("Enter a float");
      b = in.nextFloat();
      System.out.println("You entered float "+b);   
   }
}
2
On

You can use the JOptionPane class in java for generate InputBox like QTP. You can also generate the MessageBox like QTP and print the message.

For InputBox and store the value in String format:

public static void main(String[] args) {
        String First=JOptionPane.showInputDialog("Enter the Message or Number");
        String Second=JOptionPane.showInputDialog(null,"Enter the Message or Number","Input Value",JOptionPane.NO_OPTION);
        }

For MessageBox and print the message:

public static void main(String[] args) {
            JOptionPane.showMessageDialog( null, "Welcome to My Message.");
            JOptionPane.showMessageDialog(null,"Welcome to My Message.","Warning",JOptionPane.WARNING_MESSAGE);
    }