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,520 points
1,413 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,880 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
1,078 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
609 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
1,299 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,830 points
761 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
963 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,880 points
1,439 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,880 points
755 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,880 points
693 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,880 points
789 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP