Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to Use Java - JOptionPane Input Dialog
Index -> Programming, Java -> Java Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
dhanyn10




PostPosted: Mon May 04, 2015 1:55 am   Post subject: How to Use Java - JOptionPane Input Dialog

Java Input Dialog is a part of java Option Pane that allows user to input any character into the form. every character given there will become a String data type. Java Input Dialog used for program when needed a respond from user, like's asking for feedback, answer, confirmation, and more.

Then here's the simple program that use JinputPane, don?t missed to include import javax.swing.JoptionPane:
Java:
import javax.swing.JOptionPane;
public class tryJInputPane {
    public static void main(String[]args){
        JOptionPane.showInputDialog(null);
    }
}

Program will works, but it?s doesn?t give you any result to the output because the code above just to display the input dialog. To get value when user giving input any character to your input dialog, add a String data type beside your JoptionPane syntax.
Java:
import javax.swing.JOptionPane;
public class tryJInputPane {
    public static void main(String[]args){
        //every character that typed in the JOptionPane will stored into "Data"
        String Data = JOptionPane.showInputDialog(null);
        //print "Data"
        System.out.println("Your Input : "+Data);
    }
}

You may use more features from JoptionPane, like?s add a description, title for your OptionPane, and message type, and here?s the example :
Java:
String Data = JOptionPane.showInputDialog(null,"[write any description here]", "[title frame]", JOptionPane.PLAIN_MESSAGE);

that's all the tutorial about java option pane input dialog, for more tutorial, you can visit my blog
http://dhanynurdiansyah.blogspot.com/2015/05/how-to-use-joptionpane-showinputdialog.html
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: