How to open warning information error dialog in swing

0 votes
How to open warning/information/error dialog in swing?

I need standard error dialog with "Ok" button and "red cross" image. I.e. analog of org.eclipse.jface.dialogs.MessageDialog.openError()
Apr 21, 2020 in Java by kartik
• 37,490 points
208 views

1 answer to this question.

0 votes

Hello,

You can try out :

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class ErrorDialog {

  public static void main(String argv[]) {
    String message = "\"The Comedy of Errors\"\n"
        + "is considered by many scholars to be\n"
        + "the first play Shakespeare wrote";
    JOptionPane.showMessageDialog(new JFrame(), message, "Dialog",
        JOptionPane.ERROR_MESSAGE);
  }
}
answered Apr 21, 2020 by Niroj
• 82,680 points

Related Questions In Java

0 votes
1 answer

How to create text labels in Swing, Java?

In the frame, you can use the ...READ MORE

answered Aug 27, 2019 in Java by Jimmy
165 views
0 votes
1 answer

How to create password field in Swing?

Swing provides an object called JPasswordField for ...READ MORE

answered Aug 27, 2019 in Java by Bruce
113 views
0 votes
1 answer

How to get text from text box in Swing?

You can add a Button listener here. ...READ MORE

answered Aug 27, 2019 in Java by Jishan
285 views
0 votes
1 answer

What are the prerequisites to learn Hadoop in java perspective?

In my day job, I've just spent ...READ MORE

answered Oct 11, 2018 in Big Data Hadoop by Frankie
• 9,810 points
209 views
0 votes
1 answer

How is inheritance in C++ different than that in Java?

The purpose of inheritance is same for ...READ MORE

answered Feb 6, 2019 in Java by Priyaj
• 58,100 points
175 views
0 votes
1 answer

What is the reason for no ConcurrentHashSet against ConcurrentHashMap?

Hello, There's no built in type for ConcurrentHashSet because you ...READ MORE

answered Apr 8, 2020 in Java by Niroj
• 82,680 points
115 views
0 votes
1 answer

How to pass an object from one activity to another on Android?

Hello @kartik, Implement your class with Serializable. Let's ...READ MORE

answered Apr 8, 2020 in Java by Niroj
• 82,680 points
133 views
0 votes
1 answer

how to do global variable declaration in java

Hello,​ Global varriable which is defined after the ...READ MORE

answered Apr 3, 2020 in Java by Niroj
• 82,680 points
124 views
0 votes
1 answer

Error: Unable to run mksdcard SDK tool in java?

Hello, If you use  Ubuntu, you can try: sudo apt-get ...READ MORE

answered Apr 9, 2020 in Java by Niroj
• 82,680 points
130 views