JAVA PROGRAM useful GUI Create an application that has a but
JAVA PROGRAM- useful GUI..
Create an application that has a button that has “Enter your info.” When clicked it will present a dialog that has labels and text boxes that allow the user to enter their name, email, and phone number. The dialog will have buttons OK and Cancel. When the user clicks Cancel, the dialog will go away without doing anything else. When the user clicks OK, the user’s information will be extracted from the dialog, and dumped out on the console. Notice that you only are listening for Click events.
Solution
Answer :-
Enter your information:
<label >Name:</label><input type=\"text\" id=\"txtname\" placeholder=\"Name\">
<label >Email:</label><input type=\"text\" id=\"txteail\" placeholder=\"email id\">
<label >Phone Number:</label><input type=\"text\" id=\"txtphoneno\" placeholder=\"Phone Number\">
<button onclick=\"okbtn(); return false;\" id=\"btnok\" >Ok</button>
<button onclick=\"cancelbtn(); return false;\" id=\"btncancel\" >Cancel</button>
<script>
function okbtn() {
var name = $(\'#txtname\').val();
var email = $(\'#txteamilid\"\').val();
var phoneno= $(\'#txtphoneno\').val();
if (name == \"\") {
alert(\"Please enter name\");
}
else if(email==\"\"){
alert(\"Please enter email\");
}
else if(phoneno==\"\"){
alert(\"Please enter Phone Number\");
}
else{
alert(name +\"\" +email+\"\"+phoneno);
}
}
function cancelbtn(){
alert(\"This user information not available? \");
}
</script>
