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
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
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 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 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
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
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
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
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
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
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
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
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
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
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
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 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
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 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
Upload and display image and text records using JSP and Oracle
Upload and display image and text records using JSP and Oracle  Hi all, I'm using JSP and Oracle 10g. I could retrieve and display records from database. But i couldnot retrieve and display image. I want to store
JOptionPane Validation
On entering the integers, it will display error message: JOptionPane Integer...JOptionPane Validation JOptionPane allow you to create dialog boxes easily... look complex. Here we are going to validate the textfield of JoptionPane dialog
code to display images using 2d array - Swing AWT
code to display images using 2d array  HI !! I have an image file in ascii/binary format (lines & pixels) in the form of a 2d-array. I would like to display this using java code. I am relatively new to coding
filter and display html table data using ajax - Ajax
filter and display html table data using ajax  Hi i am stuck up... to DisplayCategory.jsp i want to display the data retrieved from the session in a 2d array on DisplayCategory.jsp in the form of the html table using responseText. how to do
Retrieve image from database using servlet and display in JSP
Retrieve image from database using servlet and display in JSP  Hi, I... to use MySQL Database from JSP page. How to retrieve image from database using servlet and display in JSP? Thanks
Display current time & system properties using JSP expressions
Display current time & system properties using JSP expressions In this Section ,we will display current time and system properties using JSP...; This JSP expression display current date.   <
Set Color in JOptionPane
Set Color in JOptionPane       In this section, you will learn how to set color in JOptionPane. Now to do this, we have used UIManager class which is responsible for look and feel. Using
Display Logo on login form using swing
Display Logo on login form using swing In this tutorial, you will learn how to display a logo in login form using swing components. Here is an example where... file from the system and using setIcon() method, the image as a logo will get
display
display  please tell me how to display the content from database.. if we click on any image using servlets/jsp...please
Set text color in JoptionPane
Set text color in JoptionPane In this section, you will learn how to set text color in JOptionPane. Now to do this, we have used UIManager class which is responsible for look and feel. Using following key value pair, we have set the text
joptionpane - Java Beginners
joptionpane   I need joptionpane showinputdialog textbox integer validation. Please send the sample code for me. Please its very urgent.... Thanks, Valarmathi  Hi Friend, Try the following code: import
joptionpane - Java Beginners
joptionpane  Hi, I need joptionpane showinputdialog textbox string validation. Please send the sample code for me. Please its very urgent.... Thanks, Valarmathi  Hi Friend, Try the following code: import
Array in JOptionPane - Java Beginners
Array in JOptionPane  Hello, I'm having trouble with printing an array in a JOptionPane. I am supposed to make a 2 dimensional int array called BlasTable. I'm supposed to use a method to print the array in a JOptionPane
Display image on JSP page using XML
Display image on JSP page using XML  ... can display a image on JSP page by using XML.  This example will examine how to parse and expose XML information using the JAXP with a JSP page

Ads