You can use the static method showMessageDialog() of JOptionPane class to display the error messages. For the 'parentcomponent' parameter in this function, you can use "null". A simple app to display error message can be:
Here, fourth parameter( which can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE ) tells the the type of message to be displayed
But, do keep in mind that each 'showXxxDialog()' method of JOptionPane blocks the current thread until the user's interaction is complete.
Displaying Error messages and using dialog boxes
Electrican_MV
Hi,
You can use the static method showMessageDialog() of JOptionPane class to display the error messages. For the 'parentcomponent' parameter in this function, you can use "null". A simple app to display error message can be:
import javax.swing.*;
public class jopt {
public static void main( String args[] ) {
JOptionPane.showMessageDialog(null, "error", "error", JOptionPane.ERROR_MESSAGE);
}
}
Here, fourth parameter( which can be ERROR_MESSAGE,
INFORMATION_MESSAGE,WARNING_MESSAGE,QUESTION_MESSAGE, orPLAIN_MESSAGE) tells the the type of message to be displayedBut, do keep in mind that each 'showXxxDialog()' method of JOptionPane blocks the current thread until the user's interaction is complete.
thanks
Prem