Displaying Text in a Dialogue Box!

Hello guys! In this article I’m going to tell you a code, that gets any text that you right in a dialogue box! Its pretty simple to do it! There’s no high-level coding needed here, you don’t even need basic GUI knowledge.

So, the code that we use for this purpose is:

    JOptionPane.showMessageDialog(null , “Welcome to Java!”);

in this specific situation, ‘Welcome to Java‘ is the text that we want to display in a dialogue box! Anything that you type in those quotation marks will be displayed in the dialogue box! Another thing to remember is that, to use JOptionPane class, we have to import javax.swing.JOptionPane.

For example:

Syntax of using JOptionPane class.
Syntax of using JOptionPane class.

 

Output
Output