JOptionPane.showMessageDialog auto closed by itself

Hi guys,
I"m facing a very weird issue. Our application is written in Swing and we encounter that the JOptionPane is automatically closed.
<code>
logger.debug( "Showing message dialog" );
JOptionPane.showMessageDialog( this,
"Some message" );
logger.debug( "Message dialog returned" );
</code>
In the logs we have found out that it printed both directly. The user didn't have the chance to click OK button.
We are using JDK 1.5.0_15, Windows XP Pro SP2
Thanks.

You need to create a "Short, Self Contained, Compilable
and Executable, Example Program (SSCCE)",
see http://homepage1.nifty.com/algafield/sscce.html,
that demonstrates the incorrect behaviour, because I can't
guess exactly what you are doing based on the information provided.
Don't forget to use the "Code Formatting Tags",
see http://forum.java.sun.com/help.jspa?sec=formatting,
so the posted code retains its original formatting.

Similar Messages

  • JOptionPane.showMessageDialog vs JOptionPane.showInternalMessageDialog

    This is my first post to the message boards, so please don't be too hard on me if this is really obvious...
    I'm trying to show a pop-up box with a message to indicate an error to the user; the JOptionPane.showMessageDialog works just fine, however when I use JOptionPane.showInternalMessageDialog, I get a NullPointerException being thrown by the L&F component(s) as follows (I'm currently running this as an applet via appletviewer):
    Exception occurred during event dispatching:
    java.lang.NullPointerException
    at javax.swing.plaf.metal.MetalLookAndFeel.getPrimaryControlDarkShadow(MetalLookAndFeel.java:1083)
    at javax.swing.plaf.metal.MetalBorders$OptionDialogBorder.paintBorder(MetalBorders.java:188)
    at javax.swing.JComponent.paintBorder(JComponent.java:574)
    at javax.swing.JComponent.paint(JComponent.java:740)
    at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:23)
    at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:54)
    at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:91)
    at java.awt.Container.paint(Container.java:960)
    at java.awt.Container.update(Container.java:981)
    at sun.awt.RepaintArea.update(RepaintArea.java:337)
    at sun.awt.motif.MComponentPeer.handleEvent(MComponentPeer.java:404)
    at java.awt.Component.dispatchEventImpl(Component.java:2722)
    at java.awt.Container.dispatchEventImpl(Container.java:1214)
    at java.awt.Component.dispatchEvent(Component.java:2556)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:333)
    at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
    I guess that I've really got two questions about this whole thing... 1) What could be causing the NullPointerException and 2) What is the real difference between JOptionPane.showMessageDialog and JOptionPane.showInternalMessageDialog?

    Here's the call that I'm using to the function -- sorry for not posting that originally...
    JOptionPane.showInternalMessageDialog( this, getString( "Messages.NoPOsSelected" ), "Error", JOptionPane.ERROR_MESSAGE );Where "this" should be the applet itself, since this is being called from a function within the JApplet.

  • Missing message on JOptionPane.showMessageDialog

    Hi,
    I created two JTrees and drew a line from a node in one tree to a node in another tree.
    After the mouse was released, I showed a message using JOptionPane.showMessageDialog(null, message). The message was not displayed. But if I show the message dialog box before I draw the line,
    the message is displayed.
    Could someone point me the possible problems or any similar example code?
    Thanks in advance!
    Jing

    Hi,
    First of all thanks for ur reply.I think u r not getting my point i don't want that my process waits for the JDialog to be closed.I want that my first Dialog should close automatically when my next Dialog pop up.My application requirement is i want to show two types of dialog one is when my work is going on "Please wait.." and another is when my work has beeen completed confimation message "Work has been completed".I want that when my work has beeen completed then my "Please wait.." dialog box should close automatically and confimation message dialog box should pop up.Plz guide me how i can do that.
    Regards
    Bikash

  • Problem wit JOptionPane.showMessageDialog

    I'm not getting where is the problem here,
    JTextField = AlteKarte,jtf3;
    jtf3.addFocusListener(new FocusListener() {
    public void focusGained(FocusEvent e) {
    public void focusLost(FocusEvent e) {
    if (!e.isTemporary() && isEnabled() ) {
    String Alte = AlteKarte.getText();
    String FoneNum = jtf3.getText();
    if (Alte.length() != 0 ){
    if(Alte.equals("123") != FoneNum.equals("123")) {
    JOptionPane optionPane = new JOptionPane();
    int answer =((Integer)optionPane.getValue()).intValue();
    JOptionPane.showMessageDialog(MainEPOS.frame,"Geben Sie bitte gultige Karten-Seriennummer an.","Fehler",JOptionPane.WARNING_MESSAGE,null);
    if(answer == JOptionPane.OK_OPTION || answer == JOptionPane.CLOSED_OPTION){
    jtf3.requestFocus(true);
    [\code ]
    i'm getting java.lang.ClassCastException at line int answer =((Integer)optionPane.getValue()).intValue();
    [\code]

    i have made it this way :-
             jtf3.addFocusListener(new FocusListener() {
                  public void focusGained(FocusEvent e) {
                  public void focusLost(FocusEvent e) {
                    if (!e.isTemporary() && isEnabled() ) {
                      String Alte = AlteKarte.getText();
                      String FoneNum = jtf3.getText();
                      if (Alte.length() != 0 ){
                           if(Alte.equals("123")  != FoneNum.equals("123")) {
                       JOptionPane optionPane = new JOptionPane();
                       Object[] options = {"OK"};
                       int answer =   JOptionPane.showOptionDialog(MainEPOS.frame,"Geben Sie bitte gultige Karten-Seriennummer an.","Fehler",JOptionPane.WARNING_MESSAGE,JOptionPane.OK_OPTION, null, options, options[0]);
                     //  int answer =((Integer) optionPane.getValue()).intValue();
                       if(answer == JOptionPane.OK_OPTION || answer == JOptionPane.CLOSED_OPTION){
                            jtf3.requestFocus(true);
          });but now the problem is, that it does not get closed at once.
    When i click OK then message appears again, and in second attempt it works.

  • Mouse click on OK is not recognised in JOptionPane.showMessageDialog

    JOptionPane.showMessageDialog(frame, longMessage,
    shortMessage,JOptionPane.ERROR_MESSAGE);
    Strangely, when the above dialog pops up, I am unable to click OK using the mouse. But pressing enter / space on OK works. Also closing the window works. Could some one please tell me why click on OK doesn't work. I am JRE 1.4.1.02. This seems to have worked in JRE 1.3.1
    Your help is much appreciated.

    just try this buddy
    hope it fits yr requirement
    int result = JOptionPane.showConfirmDialog(null,
    "Do you want to exit ",
    "Exit ?",
    JOptionPane.YES_NO_OPTION);
    if (result == JOptionPane.YES_OPTION)
    System.exit(0);
    rgds
    ASHWIN

  • Dispute case auto closing

    Hi,
    I have created a dispute case on customer noted item, when i will reverse the noted item the dispute case is not auto closed, it is still in open status.
    can any one give me solution for this.
    Regards,
    Prakash

    Hi,
    I have read already but my problem is i have created a noted item for which if i post advance receipt then i will go preclosed, but when i cancel the noted item it will still be open, i need close it pre closed manually.
    regards,
    Prakash

  • Auto closing of open Purchase Orders

    hai all
    My requirement is to find all the Auto closing of open Purchase Orders which donu2019t have any more use in business transaction
    using BAPI.pls send me one sample report
    regards
    Asish.

    Hi Lebogang
    Go to the open items list under sales or purchasing reports, select PO's on the top right and then highlight all the PO's you want to close. Then right click on the grey area on top of the report and select close. This will close all at once.
    Kind regards
    Peter Juby

  • JOptionPane.showMessageDialog() - word wrapping exceptions?!

    Hey ppl,
    Probably a silly question...
    I'm currently working with JDBC, and SQLexceptions can be very long! Currently displaying them in a JOptionPane.showMessageDialog() (as i guess most people do?), but being so long they cause it to span the whole screen & then some!
    I looked through the JOptionPane API, but didn't spot anything that might help. Is there a way to get this exception to dispaly on multiple lines, kinda like word wrap in notepad?
    Cheers for any suggestions.
    Jim

    I can't speak for other developers..But as for myself, I rarely if ever print error messages to the JOptionPane. Almost always, I print my error messages and the stack if necessary, to the ouput. This is either a command line window, console, log file, or output screen in an ide depending upon how you program. My code looks something like this.
    catch(Exception e)
        System.out.println(e.getMessage());  // Will print only the message property of the exception
        e.printStackTrace();  // Will print the stack for more information
    }Sorry I couldn't answer your question directly. Maybe someone else can. Hope I was helpful anyway.

  • Change Button Name in JOptionPane.showMessageDialog

    Hello,
    I've written the following code that invokes a JOPtionPane messageDialog, when the delete button is hit in the following frame and the selectedItem in the JComboBox is Default.
    I want to change the JOPtionPane button name from OK to Close. Is there a way to do this with error message dialoges, as their is with confirmDialoges?
    Please help out.
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    public class MyJOptionPaneTest {
         public MyJOptionPaneTest()
              JFrame frame = new JFrame("My Frame");
              JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT,5,0));
              final JComboBox myComboBox = new JComboBox();
              myComboBox.setPreferredSize(new Dimension(100,20));
              myComboBox.getModel().setSelectedItem("Default");
              myComboBox.addItem("Default");
              myComboBox.addItem("Other");
              JButton deleteButton = new JButton("Delete");
              deleteButton.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        if(myComboBox.getSelectedItem().equals("Default"))
                             JOptionPane.showMessageDialog(null, "Default cannot be deleted", "Error", JOptionPane.ERROR_MESSAGE);
              panel.add(myComboBox);
              panel.add(deleteButton);
              frame.getContentPane().add(panel);
              frame.setSize(200,100);
              frame.setResizable(false);
              frame.setVisible(true);
         public static void main(String [] args)
              MyJOptionPaneTest test = new MyJOptionPaneTest();
    }

    Hi,
    yes, I've looked at the tutorials. But there is no way to change button title for JOptionPane.showMessageDialog. Only JOptionPane.showOptionsDialog provides you w/ that feature, becuz it provides the parameter in the method.
    I was wondering if there was another way to do this for showMessageDialog.

  • InputVerifier and JOptionPane.showMessageDialog

    Since I have intalled JDK 1.4. I have got the following Problem:
    in the verify Method there is a call to JOptionPane.showMessageDialog
    in order to show a error message if the input doesn�t match and before false is returned.
    It doesn�t work anymore with 1.4. In case of error, the message Dialog is not coming up and the verify methodis just called in a endless loop.

    try setting the InputVerifier to null before displaying the JOptionPane, then set it back after the JOptionPane.
    textField.setInputVerifier(null)
    JOptionPane.showMessageDialog(...)
    textField.setInputVerifier(this)

  • Auto closing curly braces

    Is there any options in Dreamweaver 8 that is capable of auto
    closing curly braces and parenthesis like I see in a lot of code
    editors. I'm trying to use the coding environment. Thanks.

    Nope. Please suggest this to the dev team, though -
    http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "monfreex" <[email protected]> wrote in
    message
    news:evpm3j$f5s$[email protected]..
    > Is there any options in Dreamweaver 8 that is capable of
    auto closing
    > curly braces and parenthesis like I see in a lot of code
    editors. I'm
    > trying to use the coding environment. Thanks.

  • Auto closing of dispute cases--only for some company codes

    Hi
    We have activated dispute management for several company codes in our system. The auto closing of dispute cases also has been activated in status management. Cases are automatically closed by the system (through a batch job) when the last disputed object is cleared.
    Now there is a requirement to deactivate auto closing only for some company codes. They want to close cases manually in these company codes.
    Is this possible and if so how?
    Regards
    Raj.

    You cannot deselect at a company code level.
    Can we go through you proposed process.
    So you have a dispute for $100.
    The customer pays it and the dispute closes.
    Then the customer calls up and says they have an issue with the invoice they paid previously.
    I have seen this happen before but there was a little twist
    1 - The customer raised a debit note against the client for the issue that they had. The original invoice is cleared but a debit note is created and then disputed and processed. So you can close the original dispute and create a new dispute against the debit note
    2 - The customer paid the wrong invoice. The dispute was closed. However to rectify the miss allocation the clearing document will be reversed meaning the dispute is "re-opened" and can be processed.
    I am unaware of any other requirement for a customer to "re-dispute" a paid item in SAP.

  • JOptionPane.showMessageDialog ( ERROR_MESSAGE)

    hi can anyone help...
    i am using a
    JOptionPane.showMessageDialog ( ERROR_MESSAGE)
    to validate my input in some textfields... and when
    there is an ERROR the merror message will pop up...
    how to write the code so that when the user click the
    OK button inside the pop-up msg , the button can
    handle some functions as to reset some variable....??

    If you read the javadocs for JOptionPane you will find that the dialog you get from calling any JOptionPane.showXXXDialog method is modal. Consequently, when you have called showMessageDialog the current thread will be blocked until the user presses the OK button. So you can just put your reset handling code after the call to showMessageDialog, like the following little program demonstrates:
    import java.awt.event.*;
    import javax.swing.*;
    public class OptionPaneErrorTest {
        public static void main(String[] args) {
            ApplicationFrame app = new ApplicationFrame();
            app.setVisible(true);
        private static class ApplicationFrame extends JFrame {
            public ApplicationFrame() {
                JButton btn = new JButton("Click Me");
                btn.addActionListener( new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        JOptionPane.showMessageDialog(null, "This is an error message", "Error", JOptionPane.ERROR_MESSAGE);
                        System.out.println("This will get printed when the user presses the OK button");
                getContentPane().add(btn);
                pack();
    }Hope this helps.

  • How to activate a link in JOptionPane.showMessageDialog()

    i have the following code (the color of "Email Me" is blue)
    JOptionPane.showMessageDialog
       parent,
       "<html><a href=\"mailto:[email protected]\">Email Me </a></html>"
       "dialog title",
       JOptionPane.PLAIN_MESSAGE
    );"Email Me" is blue and underlined but nothing happened when clicked on.
    please help. thanks.

    hi ra
    good question dear
    if you want to activate cube in business content do this steps.
    1).select your data source and maintain all the things in r/3 side.
    2).then come to bi side .
    3).t-code rsorbct.
    4).you must have an idea about your app component .i..e that app belongs to sd or mm or hr or finance .
    5).if it belongs to purchasing select infoobj and select supply chain management ,select purchasing.
    6).select char and key fig,drag and drop it into right side component .
    7).select info provider select supply chain management and select your cube .
    8).how to find cube .that is cube like 0pur_c01,c02,c03,c04 like that select any of the cube and drop in to right side component .
    9).now installation part.
    10).select source system top side and select your source ecc 6.0, select component and select install/activate.
    11).now your cube is ready to use .create package for full,initialize ,delta.ok
    bye ....................samar reddy...

  • Photoshop cs5 and cs6 closing by itself?

    Hello,
    On a PC with XP.
    Recently cs5.1 extended started closing by itself after being open for just a few minutes.
    Upgrade to cs6 today and the same thing happened:
    Opened photoshop, created a .psd file, added color and text, left the program and it closed by itself.
    Don't understand.  Help.
    Thanks
    John

    There's really no way anyone's going to be able to diagnose the problem based on just what you have said.
    Chances are a display driver update or something that's been installed/changed on your system has made the environment unstable or insufficient for Photoshop to work.
    You might even have contracted malware.
    Something's wrong with your system.  You might even have to go so far as to either restore from a backup to a time in which it was working, or do a fresh install.
    If you do have to start over, I recommend you consider upgrading to a modern operating system.
    -Noel

Maybe you are looking for