i want to display a message dialog box in java. At this moment i can only display a message in a console by using System.out.println()
method
Example :
public class demo{
public static void main(String[] x){
// i want to display the below message in a dialog box
System.out.print("java is fun");
}
}
use JOptionPane.showMessageDialog()
method and you can define some or all the arguments of the method
Code example :
import javax.swing.JOptionPane; // import javax packages
public class demo {
public static void main(String[] args){
// using showMessageDialog(component parentComponent,String message,String messageTitle,int optionType) method to display a message dialog box
JOptionPane.showMessageDialog(null,"java is fun","Title",1);
}
}
use this code
JOptionPane.showMessageDialog(null, "java is fun");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With