Get and Display using JOptionPane

Get and Display using JOptionPane

Hello everyone,

I have been asked by my lecturer to do a simple program. But, I don't have the idea how to start on in because this is my first time handling java. She ask to get some data from student, name and age, by using JOptionPane. Then display it.

Really appreciate your help if you guys can help me in my studies.

Thanks everyone

View Answers

February 13, 2012 at 11:21 AM

import javax.swing.*;

class JOPtionPaneExample 
{
    public static void main(String[] args) 
    {
        String name=JOptionPane.showInputDialog(null,"Enter Name: ");
        int age=Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Age: "));
        JOptionPane.showMessageDialog(null, "Name is: "+name+" and Age is: "+Integer.toString(age));
        System.out.println("Name is: "+name+" and Age is: "+Integer.toString(age));
    }
}









Related Tutorials/Questions & Answers:
Get and Display using JOptionPane
Get and Display using JOptionPane  Hello everyone, I have been... on in because this is my first time handling java. She ask to get some data from student, name and age, by using JOptionPane. Then display it. Really
Selection Using JoptionPane
Selection Using JoptionPane  Help, can someone provide me the code using JOptionPane for the following:- Part A 1) Prompt user to make 3 selection... to quit, display the total cost of the two items; otherwise, display the total
Advertisements
Unable looping using JOptionPane - Java Beginners
Unable looping using JOptionPane  import javax.swing.*; public class Shop{ public static void main(String [] args){ Shop shop = new Shop(); String mainMenu= "(MAIN SCREEN )"; mainMenu+= "\n1) Computer Menu
Display JList value selected from the JOptionPane
Display JList value selected from the JOptionPane In this section, we are going to select the particular value from the JOptionPane combobox and displayed.... To proceed further, when the user click the button, the JOptionPane with combobox
how to display jsp page containing mysql query in particular division using ajax ?my code is below bt i cundt get it properly
how to display jsp page containing mysql query in particular division using ajax ?my code is below bt i cundt get it properly   index.html <...; } } } request.open("GET", "newjsp.jsp", true); // Create a function
display image using jsp
display image using jsp  display image using jsp and phonegap on emulator of eclipse   Here is a simple jsp code that displays an image on browser. <%@ page import="java.io.*" %> <%@page contentType="image/gif
By using Applet display a circle in a rectangle
By using Applet display a circle in a rectangle  Write a java applet to display a circle in a rectangle
get and display blob from mysql on jsf
get and display blob from mysql on jsf  i want to get blob from mysql, and display on jsf page. your examples with jsp. i dont find an example with jsf. plese help me about this. thanks..   Have a look at the following
Display Hello even before main get executed??
Display Hello even before main get executed??  I have a class (main method) as follow.....As I know this can be done using static method, but Q...;class Hello{ static void display(){ System.out.print("Hello
Display helloworld using servlet in jboss
Display helloworld using servlet in jboss  import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorld.... When i runned ma deploy.cmd, I get a message like NO SUCH FILE OR DIRECTORY,I'm
Exporting to excel using display tag?
Exporting to excel using display tag?  Hai , I am implementing pagination in struts.It has export to excel option.When I am clicking on it ,it is displaying a alert box stating "the file you are trying to open
Write a query to display a row using index
Write a query to display a row using index  Write a query to display a row using index
Using JFreeChart to display recent changes in a time series
Using JFreeChart to display recent changes in a time series  Using JFreeChart to display recent changes in a time series
Display Image using Toolkit.getImage()
Display Image using Toolkit.getImage()       This section illustrates you how to display the specified image using Toolkit.getImage() method. To display the image, put an image
Display Multiple Images in jscrollpane using Java Jpanel
Display Multiple Images in jscrollpane using Java Jpanel  Browse and Display multiple images in vertical view of java jscrollpane using jpanel
joptionpane validation
joptionpane validation  import javax.swing.*; import java.util.regex.*; public class joptionpane { public static void main(String[] args... help me!i need to validate the user input on the joptionpane,and if the user
how to get HTTP GET request value using javascript
how to get HTTP GET request value using javascript  how to get HTTP GET request value using javascript   how is how you can get HTTP GET request value using javascript: var parameter = window.location.search.replace
Display Errors using Message Resources - Struts
Display Errors using Message Resources  Hello.. I've a login page where i used applicationresources.properties to display errors for null values... required.. I want to display errors using message resources using
display Helloworld through servlets using jboss
display Helloworld through servlets using jboss  I'm beginner,Can You please Write the code for this.Including WEB.INF   Please visit the following link: http://www.roseindia.net/jboss
how to display a table from database using servlet
how to display a table from database using servlet  how to display a table with values from servletpage   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 http://roseindia.net/jsp/servlet-jsp-data
Html form using JavaScript to display the table content
Html form using JavaScript to display the table content  HI There, Greetings, I am new to this java and I need your assistance. I have created... want to write a Html JavaScript coding to display the content from database
how to display selected checkboxes dynamically using jsp
how to display selected checkboxes dynamically using jsp  Hi friends i have a requirement that : in my JSP page i have radio buttons followed by the DB fields..when i click SUBMIT button,if the field(or record
how to get harddisk info using S.M.A.R.T using java
how to get harddisk info using S.M.A.R.T using java   how to get harddisk info using S.M.A.R.T using java
display current time when using datetimepiker in struts2
display current time when using datetimepiker in struts2  how to display current time when using datetimepiker in struts2 I set displayFormat="dd/MM/yyyy HH:mm:ss" but it doesn't work. Display value is always : 19/11/2010 00:00
how to display values from database into table using jsp
how to display values from database into table using jsp  I want to display values from database into table based on condition in query, how to display that? For example i have some number of books in database but i want
get data between date using jsp with msaccess
get data between date using jsp with msaccess  hi, urgently i need program for get data between date using jsp with MsAccess database.plz any one can help me.thanks for anyone replay with regards c.b.chellappa
How to Using timezone_location_get() PHP
How to Using timezone_location_get() PHP  Hi, I am trying to create an application using the timezonelocationget() in PHP to retrieve the data of country code & latitude/longitude. I need the help of PHP developer who can
get from address using javamail api?
get from address using javamail api?  i want to get from address of particular mail using the javamail api? actually i had done it in one .jsp file using the particular mail number. message[messageno].getFrom()[0
How To get DgroupId while using maven.
How To get DgroupId while using maven.  Hello everyone, I read... converter ,i can't find the right "DgroupId", also i can't get how to make... project from an archetype." I can't get how to remove error by making right
read XML file and display it using java servlets
read XML file and display it using java servlets  sir, i can't access Xml which is present in my d drive plz can u should go through my code n tell me the things where i went wrong java servlet program protected void
how to send spaces using get method.
how to send spaces using get method.  hi i want to know how to send spaces using get method? for example like http://localhost:8080/Sandeep?name... code: 1)form1.jsp: <html> <form method="get" action="form2.jsp"> <
Using get method in preferences
Using get method in preferences       In this section you will learn how to use the get() method... a simple way for using the get method in preferences. Get is the most useful
How to get the output of JSP program using Bean
How to get the output of JSP program using Bean  Hi Kindly go... program for the above one by using Bean and i opened the Tomcat webserver... visit the following link: http://www.roseindia.net/jsp/using-bean-counter.shtml
How to get the output of jsp program using Bean
How to get the output of jsp program using Bean  Hello my Roseindia netizen has suggested one program but when i implement the same i am not getting...; Next i created JSP program for the above one by using Bean and i opened
get info from mysql using jsp and servlet
get info from mysql using jsp and servlet  HELLO! I wanna create a jsp page which able to let me get its name, phone and other info by asking the user to key in their email address from mysql database by using servlet and jsp too
Display tow dimensional array using one for loop in java
Display tow dimensional array using one for loop in java  Display tow dimensional array using one for loop in java
how to display duplicate elements with out using collection Frame work?
how to display duplicate elements with out using collection Frame work?  how to display duplicate elements with out using collection Frame work
Write an applet to display scrolling image in an applet window using thread.
Write an applet to display scrolling image in an applet window using thread.  Write an applet to display scrolling image in an applet window using thread
Set delay time in JOptionPane
the message should be displayed using JOptionpane. For this, first of all we prompt the user to enter time in seconds and the message to display. After that using... Set delay time in JOptionPane      
How to display on textbox using ObjectUtil class
How to display on textbox using ObjectUtil class       In this tutorial we will see how to display a text in textbox using ObjectUtil class. Here
How to display data in form using aryylist in struts - Java Beginners
How to display data in form using aryylist in struts  Hi, I want to display data using arraylist in struts pls help me Its urgent
write a java pogram to add elements to linked list using keyboard and display it
write a java pogram to add elements to linked list using keyboard and display it  write a java pogram to add elements to linked list using keyboard and display
Display tow dimensional array by matrix form using one for loop in java
Display tow dimensional array by matrix form using one for loop in java  Display tow dimensional array by matrix form using one for loop in java
Write a java program to display the season given the month using switch case
Write a java program to display the season given the month using switch case  Write a java program to display the season given the month using switch case
how to get data using dropdownlist, textbox and search button in jsp
how to get data using dropdownlist, textbox and search button in jsp  Hi, I want to display data using jsp,javascript and mysql. My Q. is If i select an entry suppose 'title' from dropdownlist and give a title name 'partial dif
joptionpane - Java Beginners
joptionpane  Hi, I need joptionpane validation. I have joptionpane inputdialog textbox.I need to enter the string values only in the textbox for validation. Please send the sample code immediately. Its very urgent
how to get the data from database&how to display the database data in jsf - Java Server Faces Questions
how to get the data from database&how to display the database data in jsf  Hi, 1.how to get the data from database. 2.how to display the database...; Hi friend, To Solve the Problem get the data from database
How to display image in jsp from database using Servlet?
How to display image in jsp from database using Servlet?  Hi, How to display image in jsp from database using Servlet? Thanks   Hi, You will find code and example program at Retrieve image from database using Servlet
How to display data in jsp from dao using java beans?
How to display data in jsp from dao using java beans?  Hi I need to display data in jsp pulling from dao using java beans, Please can anyone give me the sample application with above topics. Any help would be highly appreciated
ID using get the databse latest value and displayed in jsp
ID using get the databse latest value and displayed in jsp   I have... in the form (it means latest values) ... how to retrive that values using ID and displayed in preview.jsp page . so technically pass the new id and display the values

Ads