Display String Value using JOptionPane in Java

0
92

This tutorial is all about Display String Value using JOptionPane in Java.

JOptionPane in Java known as Dialog Box in other platform is very important in any programs, especially in Desktop Application. This JOptionPane is used to display notification or error message to a user who uses the program.

This tutorial entitled “ Display String Value using JOptionPane in Java ” will teach you on how a string value display as notification into JOptionPane. This program required jPanel, jLabel, jTextfield, jCombobox, and jButton elements inside your jFrame Form. Please follow the steps to complete this tutorial.

Display String Value using JOptionPane in Java Steps

  1. Create/Insert a new JFrame form inside your project.

2. Design your JFrame Form just look like the image below.

3. Insert the code below above your class to access  the JOptionPane library

  1. import javax.swing.JOptionPane;

4. Double click your button and insert the codes below.

  1. JOptionPane.showMessageDialog(null, "Thank you for pressing me " + jTextField1.getText() + ". Amazing! You are " +
  2. jComboBox1.getSelectedItem().toString() + "!");

5. Run your program and the output should look like the image below. A JOptionaBox appear after a button click.

Facebook Comments
(Visited 115 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here