JOptionPane Component in Java
Submitted by donbermoy on Monday, November 24, 2014 - 13:35.
This is a tutorial in which we will going to create a program that will have a JOptionPane Component in Java. A JOptionPane lets the program pop up a dialog box that will let the user informs something.
So, now let's start this tutorial!
1. Open JCreator or NetBeans and make a java program with a file name of jOptionPaneComponent.java.
2. Import the javax.swing.* package to access the JOptionPane class.
3. Initialize your variable in your Main, variable num as String.
Now, we will use the showInputDialog of the JOptionPane to make the variable num as an input dialog. Have this code below:
4. To convert the variable num as a complete integer, we will use the parse method and have it initialized as a variable.
To show the number that you have inputted, we will use the showMessageDialog method of the JOptionPane. Have this code below:
Output:
Here's the full code of this tutorial:
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- import javax.swing.*; //used to access the JOptionPane class
- String num;

- import javax.swing.*; //used to access the JOptionPane class
- public class jOptionPaneComponent {
- String num;
- }
- }
Add new comment
- 332 views