JOptionPane...

im using JOptionPane.showMessageDialog... to ask the user something. the buttons are yes and no. now, how can i know if the user has clicked yes or the no button?

Docs can help you.
http://java.sun.com/j2se/1.4.1/docs/api/javax/swing/JOptionPane.html

Similar Messages

  • Unable to return values in joptionpane

    Hi all,
    Im having a slight problem with some code regarding a joptionpane. With the help of some code i found on the internet (lol i know theres a lot of bad stuff out there but i thought id give it a go), im making a new object array containing my fields, and then adding these objects to the joptionpane. it seems to work ok, but i cant get back the values the user entered into the fields - for a normal joptionpane id call the getText() method. (nb this is only a small test application, so it is ok that a password is being returned for anyone to see!)
    In my code below, all i can get it to do is return the objects details eg javax.swing.JTextField[,0,19,195x20,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0 etc...., and not the value the user entered!
    Is this bad code for what im trying to do? what is the easiest way of returning the users password?
    Thanks in advance
    Torre
    here is the code:
    if ("changePwdPressed".equals(e.getActionCommand())){
                   Object complexMsg[] = { "Current Password: ", new JTextField(10), "New Password: ", new JTextField(10), "Confirm New Password: ", new JTextField(10) };
                   JOptionPane optionPane = new JOptionPane();
                   optionPane.setMessage(complexMsg);
                   optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
                  JDialog dialog = optionPane.createDialog(this, "Change Password");
                  dialog.setVisible(true);
                  int i;
                  for (i=0; i<complexMsg.length; i++)
                  System.out.println(complexMsg);

    This works, but it's ugly...
    package forums;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class ComplexJDialogTest
      public static void main(String[] args) {
        try {
          System.out.println("Hello World!");
          message();
          System.out.println("Hello World!");
        } catch (Exception e) {
          e.printStackTrace();
      private static void message() {
        Object messages[] = {
            "Current Password: ", new JTextField(10)
          , "New Password: ", new JTextField(10)
          , "Confirm New Password: ", new JTextField(10)
        JOptionPane optionPane = new JOptionPane(messages, JOptionPane.INFORMATION_MESSAGE);
        JDialog dialog = optionPane.createDialog(null, "Change Password");
        dialog.setVisible(true);
        for (int i=1; i<messages.length; i+=2) {
          System.out.println(((JTextField)messages).getText());
    dialog.dispose();
    ... I think I would prefer swmtgoet_x's solution... just create your three JTextField's (keep references to them) pass them to the JDialog, then (after user hits OK done) just access them directly.... ergo...
    package forums;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class ComplexJDialogTest
      public static void main(String[] args) {
        try {
          System.out.println("Hello World!");
          message();
          System.out.println("Hello World!");
        } catch (Exception e) {
          e.printStackTrace();
      private static void message() {
        JTextField oldPassword = new JTextField(10);
        JTextField newPassword = new JTextField(10);
        JTextField newPasswordAgain = new JTextField(10);
        Object messages[] = {
            "Current Password: ", oldPassword
          , "New Password: ", newPassword
          , "Confirm New Password: ", newPasswordAgain
        JOptionPane optionPane = new JOptionPane(messages, JOptionPane.INFORMATION_MESSAGE);
        JDialog dialog = optionPane.createDialog(null, "Change Password");
        dialog.setVisible(true);
        dialog.dispose();
        System.out.println(oldPassword.getText());
        System.out.println(newPassword.getText());
        System.out.println(newPasswordAgain.getText());

  • Key-enable buttons on a JOptionPane

    Hi,
    The existing code in my Application uses a JOptionPane static method = JOptionPane.showOptionDialog() to create a dialog box.Is there any way I can key-enable the buttons on the dialog created by this method.
    public int createAndShowGUI() {
    if (!issuesPanel.hasIssues())
    return -2; //TODO make constant
    else {
    //Custom button text
    String[] options = should_continue ? new String[] {returnText, continueText} : new String[] {returnText};
    int optionButtons = should_continue ? JOptionPane.OK_CANCEL_OPTION : JOptionPane.CANCEL_OPTION ;
    log.info("IssuesOptionPane displayed - " + title);
    int optionChosen = JOptionPane.showOptionDialog(parent,
    issuesPanel.createAndGetIssuesPanel(),
    title,
    optionButtons,
    JOptionPane.PLAIN_MESSAGE,
    null, //don't use a custom icon
    options, //titles of buttons
    null); //no default selected button
    String buttontext = optionChosen == CLOSE ? "X" : options[optionChosen];
    log.info("User clicked on the " + buttontext + " button");
    return optionChosen;
    I see that there is no way to get a handle on the JButtons created by the JOptionPane.So, one work around that I tried is to create a JPanel, add JButtons , set Input Map, set Action Map ( to add key bindings ) on it.Then create a JDialog and pass this JPanel to the dialog using setContentPane
         private static void createAndShowGUI(){
              JButton bookingButton=new JButton(bookStr);
              JButton returnButton=new JButton(returnStr);
              bookingButton.addActionListener(new BookAction());
              returnButton.addActionListener(new ReturnAction());
              JPanel panel=new JPanel();
              panel.add(bookingButton);
              panel.add(returnButton);
              panel.setActionMap(initActionMap());
              initAndSetInputMap(panel);
              JDialog dialog=new JDialog();
              dialog.setSize(400,100);
              dialog.setModal(true);
              dialog.setContentPane(panel);
              dialog.addPropertyChangeListener(indicator,listener);
              System.out.println("step 1" );
              dialog.pack();
              System.out.println("step 2");
              dialog.setVisible(true);
    But the problem that I am facing here is that the property change events triggered by the code inside the actionPerformed methods is not getting capturesd by the listener attached to the JDialog.
    Any thoughts?
    Thanks
    Aman

    google: JOptionPane mnemonics
    http://www.devx.com/tips/Tip/13718
    http://forum.java.sun.com/thread.jspa?threadID=321824&messageID=1649963
    http://coding.derkeiler.com/Archive/Java/comp.lang.java.gui/2005-03/0495.html
    etc.

  • Focus on JOptionPane

    I have a problem.
    If I want to change something within a table, a JOptionPane opens, in which i can enter some values.
    But if I switch to another program over the task bar while the JOptionPane is still open, and I return to my Java program over the task bar, the main window has the focus and the JOptionPane is hidden. During this, the user has no posibillity to close the program. The only possibility to get the JOptionPane back is by ALT+TAB!
    Is it possible, that the JOptionPane will over the task bar?

    Just to easy, that it is really embarassing:
    JOptionPane.showMessageDialog(frame,"Message");
    The first parameter is the parent container. If you pass your main frame, it is modal and in front of the frame!

  • JOptionPane.showInputDialog and Focus

    I have a program that allows the user to type in a String in a text box and when they hit the enter key the text will appear in a text area. I've also added a menu bar to the program. When the user clicks on File and then Connect from the menu bar I want a JOptionPane to pop up that asks for the user to type in a username and then prompt for a password. And I've gotten all of that to work. Now for the problem. I click on file from the menu bar and then connect and it prompts me for the username as it should. I am able to just type in a phrase in the text field of the username dialog box and hit the enter key and then it prompts me for my password. I am still able to type in a phrase in the text field of the password Dialog box, however when I hit the enter key, the Dialog box does not close as it did for the username Dialog box. It will still close if I click on the OK button, but just pressing the enter key does not close the Dialog box as it did when it prompted for a username. I'm thinking I need to direct the focus to the password dialog box, but not sure how to go about doing this. Any help in solving this problem would be greatly appreciated.
    Here is my code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class TestJOptionPane extends JFrame implements ActionListener{
         private static int borderwidth = 570;
         private static int borderheight = 500;
         private JPanel p1 = new JPanel();
         private JMenu m1 = new JMenu("File");
         private JMenuBar mb1 = new JMenuBar();
         private JTextArea ta1 = new JTextArea("");
         private JTextField tf1 =new JTextField();
         private Container pane;
         private static String s1, username, password;
         private JMenuItem [] mia1 = {new JMenuItem("Connect"),new JMenuItem("DisConnect"),
              new JMenuItem("New..."), new JMenuItem ("Open..."), new JMenuItem ("Save"),
              new JMenuItem ("Save As..."), new JMenuItem ("Exit")};
    public TestJOptionPane (){
         pane = this.getContentPane();
              addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
         dispose();
    System.exit(0);
         setJMenuBar(mb1);
    mb1.add(m1);
    for(int j=0; j<mia1.length; j++){
         m1.add(mia1[j]);
    p1.setLayout( new BorderLayout(0,0));
    setSize(borderwidth, borderheight);
    pane.add(p1);
              p1.add(tf1, BorderLayout.NORTH);
              p1.add(ta1, BorderLayout.CENTER);
              this.show();
              tf1.addActionListener(this);
              for(int j=0; j<mia1.length; j++){
                   mia1[j].addActionListener(this);
         public void actionPerformed(ActionEvent e){
              Object source = e.getSource();
              if(source.equals(mia1 [0])){
                   username = JOptionPane.showInputDialog(pane, "Username");
                   password = JOptionPane.showInputDialog(pane, "Password");
              if(source.equals(tf1)){
                   s1=tf1.getText();
                   ta1.append(s1+"\n");
                   s1="";
                   tf1.setText("");
         public static void main(String args[]){
              TestJOptionPane test= new TestJOptionPane();
    }

    But using JOptionPane doesn't get the focus when you call itworks ok like this
    import javax.swing.*;
    import java.awt.event.*;
    class Testing
      public Testing()
        final JPasswordField pwd = new JPasswordField(10);
        ActionListener al = new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            pwd.requestFocusInWindow();}};
        javax.swing.Timer timer = new javax.swing.Timer(250,al);
        timer.setRepeats(false);
        timer.start();
        int action = JOptionPane.showConfirmDialog(null, pwd,"Enter Password",JOptionPane.OK_CANCEL_OPTION);
        if(action < 0)JOptionPane.showMessageDialog(null,"Cancel, X or escape key selected");
        else JOptionPane.showMessageDialog(null,"Your password is "+new String(pwd.getPassword()));
        System.exit(0);
      public static void main(String args[]){new Testing();}
    }

  • Using JOptionPane to exit program & Using toString method

    Hello,
    In my program I have to use a toString method below
    public String toString(Hw1NCBEmployee[] e)
            String returnMe = String.format(getStoreName() + "\n" + getStoreAddress() + "\n" + getCityState() +  "\nYou have " + getEmpCount() + "employee(s)");
            return returnMe;
    }Now, at first, when I initially tested my code, it was working just fine, printing out the right way
    Point is -- now that Im practically finished with my program, and am going back and running it - calling the toString method gives me the address rather than the information . . . Can anyone help me with this issue??
    Also, Im using JOptionPane to display everything, but -- at first, it worked fine, then (around the same time I started having the above problem) it stopped exiting the do-while loop:
    while(go)
                 int option = JOptionPane.showConfirmDialog(null, "Do you want to enter employee information?", "Welcome!", JOptionPane.YES_NO_OPTION);
                     if(option == JOptionPane.NO_OPTION)
                        go = false;  //exit loop
            

    ncjb wrote:
    well, for the toString - I have to print out the info inside the array -- am I right in thinking that the only way to do this is to pass in the array ??If the array is part of the class then there is no need to pass it as a parameter. If it is being passed in from outside the class then I have to question your design. Why should class X being formatting data that is not a representation of itself?
    and i have 2 other files that go with this program . . . I just want to know if there is a way to make sure that when the user presses the NO option, it will exit the loop -- the piece of code you see if apart of an entire method (not long) -- do you want me to include this??You read that link I provided REAL quick!

  • How to setup background color in the options of JOptionPane

    Hi
    I need to highlight the background of options of JOptionPane in different colors. Ex. 1~5 options in green and 6~10 options in red color.
    Does any one know how to do it?
    Thanks in advanced.

    Can you work out what the actual HTML is to do
    "Whatever it was that you wanted to do" ? { I couldn't understand that }
    I.e If you make up a Test table, with Your Text editor can you get a sample output that looks like you want?
    But the problem is i am able to change the background of the full cell. But i don't need to change the background of the full cell always. For example if Nextti value is 15/1/2005 & Duration is 30 then the shade should start from the middle of January Cell (because of the date 15th)end in the middle of next cell (February). If the duration is 15 then it should end in the (January) same end of cell.
    Is this something that can be done in HTML?
    If your question is 'amenable' to HTML, figure out conditions for which you want to Set a certain color....
    If the color in one cell for instance depends on the Next Cell, then you're going to have to buffer the whole Table ROW....
    Set which ones should be RED for instance, then output that ROW in HTML...
    If you are using Java for this, then also be aware that you might need to escape certain characters like use "\\" to get "\"
    You'd also probaly have an easier time, however you are doing this if you used some sort of CSS .......

  • How to get Title from JOptionPane

    Hi,
    I would like to get Title from a JOptionPane, is there any method to get the same? for example, a message dialog has "Error" as title how can I get it?
    Thanks in advance.
    -Jose

    Hi Jose,
    Do you mean you want to set the title? If so you can specify the title in one of the many static methods available ie.
    JOptionPane.showMessageDialog(parent, "some message", "some title", JOptionPane.ERROR_MESSAGE);
    Otherwise if you are trying to get the title try..
    String title = "some title";
    JOptionPane.showMessageDialog(parent, "some message", title , JOptionPane.ERROR_MESSAGE);
    then you can write some other code using title.
    Hope this helps Jose,
    regards Darren.

  • Key mapping for JOptionPane

    My problem is pretty simple. When presented with a YES_NO_CANCEL option, I want the escape key to trigger the CANCEL operation.
    I've tried numerous methods including creating my own JOptionPane, adding/removing KeyListeners, etc., but I can't seem to get around this default behavior. Any suggestions?
    Michael

    By default, the Esc key closes the dialog with a return value of JOptionPane.CLOSED_OPTION. Why can't you simply perform the same action as when the return value is JOptionPanel.CANCEL_OPTION ?
    db
    edit Or even reassign the return value, if you prefer to do that (I wouldn't)int retVal = JOptionPane.showOptionDialog(...);
    if (retVal == JOptionPane.CLOSED_OPTION) {
       retVal = JOptionPane.CANCEL_OPTION;
    }Edited by: Darryl.Burke

  • The problem with the return code of JOptionPane

    I debug the follow code, when I press button No, return code is 0, but OpenXLSFile(ResultXSLName); executed, why?
    the result is whether I press YES or NO, the if condition will be true
    how to compare the return code?
              int open = JOptionPane.showConfirmDialog(null, "Do you want Open the result File \"" + ResultXSLName + "\" ?", "Confirm", JOptionPane.YES_NO_OPTION);
              if (JOptionPane.YES_OPTION == open);
                   OpenXLSFile(ResultXSLName);
              }Edited by: Kevin.Tong on Feb 26, 2008 7:26 PM

    the result is whether I press YES or NO, the if condition will be truethis line will execute
    OpenXLSFile(ResultXSLName);regardless of the condition being true or false,
    because the if statement terminates at the semi-colon
    if (JOptionPane.YES_OPTION == open);<------------------

  • Problem in Displaying JOptionpane Message Dialog (JRE 1.5.0_04 or later)

    Hi! All,
    I am getting a deadlock kind a situation while displaying JOptionpane message dialog. It's very rare to simulate also. I am also posting the Thread dump which i have taken programmatically, when this situation arises.
    For your Information, I am using JRE 1.5.0_04 or later version on Windows XP.
    We searched on Java.sun.com site, & we got that two bugs are related to our problem, but there are arises in JRE 1.4.2 or before version & have been fixed at JRE 1.5 .
    Follwing are the bugs ID in Sun Bugs Database: 4978089, 4828019.
    Can anyone suggest me which is the stable JRE 1.5 version to avoid this problem. Also can anyone suggest me the workaround of this problem. I want to fix this in our application ASAP.
    following is My Thread Dump :
    Thread[Finalizer,8,system]
         java.lang.Object.wait(Native Method)
         java.lang.ref.ReferenceQueue.remove(Unknown Source)
         java.lang.ref.ReferenceQueue.remove(Unknown Source)
         java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
    Thread[Java2D Disposer,10,javawsApplicationThreadGroup]
         java.lang.Object.wait(Native Method)
         java.lang.ref.ReferenceQueue.remove(Unknown Source)
         java.lang.ref.ReferenceQueue.remove(Unknown Source)
         sun.java2d.Disposer.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thread[JCIL_Sess(813251)_EvtThd(24880015),5,main]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         java.awt.EventQueue.invokeAndWait(Unknown Source)
         javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
         in.co.netsol.telecom.desktop.CallAppearanceTable$EventAdapter.OnCallEstablished(CallAppearanceTable.java:982)
         in.co.netsol.telecom.ctios.events.EventSinkAdapter.OnEvent(EventSinkAdapter.java:142)
         com.cisco.cti.ctios.cil.EventPublisher.PostEvent(EventPublisher.java:175)
         com.cisco.cti.ctios.cil.EventPublisher.FireEvent(EventPublisher.java:142)
         com.cisco.cti.ctios.cil.CtiOsSession.FireEvent(CtiOsSession.java:1849)
         com.cisco.cti.ctios.cil.Call.FireEvent(Call.java:254)
         com.cisco.cti.ctios.cil.Call.OnCallEstablishedEvent(Call.java:1136)
         com.cisco.cti.ctios.cil.Call.OnEvent(Call.java:943)
         com.cisco.cti.ctios.cil.CtiOsSession.OnEvent(CtiOsSession.java:2107)
         com.cisco.cti.ctios.cil.CilServiceEvent.ReceiverThread(CilServiceEvent.java:256)
         com.cisco.cti.ctios.cil.CilServiceEvent$1.run(CilServiceEvent.java:173)
    Thread[pool-1-thread-5,5,main]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         java.awt.EventQueue.invokeAndWait(Unknown Source)
         javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
         in.co.netsol.telecom.desktop.command.MakeAgentReadyCommand$EventAdapter$1.run(MakeAgentReadyCommand.java:190)
         java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
         java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thread[DestroyJavaVM,5,main]
    Thread[AWT-Shutdown,5,javawsApplicationThreadGroup]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         sun.awt.AWTAutoShutdown.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thread[JCIL_Conn(18096534)_Watchdog,5,main]
         java.lang.Object.wait(Native Method)
         com.cisco.cti.ctios.util.UnNamedEvent.WaitForSingleObject(UnNamedEvent.java:147)
         com.cisco.cti.ctios.cil.CilConnection.WatchdogThread(CilConnection.java:527)
         com.cisco.cti.ctios.cil.CilConnection$1.run(CilConnection.java:1071)
    Thread[AWT-EventQueue-0,6,main]
         java.awt.Container.getComponents_NoClientCode(Unknown Source)
         java.awt.Container.getComponents(Unknown Source)
         javax.swing.JToolBar.getComponentAtIndex(Unknown Source)
         javax.swing.plaf.basic.BasicToolBarUI.navigateFocusedComp(Unknown Source)
         javax.swing.plaf.basic.BasicToolBarUI$Actions.actionPerformed(Unknown Source)
         javax.swing.SwingUtilities.notifyAction(Unknown Source)
         javax.swing.JComponent.processKeyBinding(Unknown Source)
         javax.swing.JComponent.processKeyBindings(Unknown Source)
         javax.swing.SwingUtilities.processKeyBindings(Unknown Source)
         javax.swing.UIManager$2.postProcessKeyEvent(Unknown Source)
         java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
         java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
         java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
         java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
         java.awt.Component.dispatchEventImpl(Unknown Source)
         java.awt.Container.dispatchEventImpl(Unknown Source)
         java.awt.Window.dispatchEventImpl(Unknown Source)
         java.awt.Component.dispatchEvent(Unknown Source)
         java.awt.EventQueue.dispatchEvent(Unknown Source)
         java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         java.awt.EventDispatchThread.run(Unknown Source)
    Thread[AWT-Windows,6,main]
         sun.awt.windows.WToolkit.eventLoop(Native Method)
         sun.awt.windows.WToolkit.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thread[Timer-0,5,javawsApplicationThreadGroup]
         java.lang.Thread.dumpThreads(Native Method)
         java.lang.Thread.getAllStackTraces(Unknown Source)
         in.co.netsol.telecom.log.ThreadDumpLoggingTask.getStackTraces(ThreadDumpLoggingTask.java:47)
         in.co.netsol.telecom.log.ThreadDumpLoggingTask.run(ThreadDumpLoggingTask.java:36)
         java.util.TimerThread.mainLoop(Unknown Source)
         java.util.TimerThread.run(Unknown Source)
    Thread[JCIL_Conn(18096534)_Rcvr,5,main]
         java.net.SocketInputStream.socketRead0(Native Method)
         java.net.SocketInputStream.read(Unknown Source)
         com.cisco.cti.ctios.cil.NetPort.ReceiveData(NetPort.java:405)
         com.cisco.cti.ctios.cil.NetPort.ReceiveData(NetPort.java:363)
         com.cisco.cti.ctios.cil.CilPacket.ReadFromPort(CilPacket.java:649)
         com.cisco.cti.ctios.cil.CilConnection.ReadPacket(CilConnection.java:670)
         com.cisco.cti.ctios.cil.Connection.ReceiverThread(Connection.java:398)
         com.cisco.cti.ctios.cil.Connection$1.run(Connection.java:472)
    Thread[pool-1-thread-2,5,main]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         java.awt.EventQueue.invokeAndWait(Unknown Source)
         javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
         in.co.netsol.telecom.desktop.command.SupervisorAssistCommand$EventAdapter$1.run(SupervisorAssistCommand.java:152)
         java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
         java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thread[pool-1-thread-1,5,main]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         java.awt.EventQueue.invokeAndWait(Unknown Source)
         javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
         in.co.netsol.telecom.desktop.command.ConferenceCallCommand$EventAdapter$1.run(ConferenceCallCommand.java:144)
         java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
         java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thread[JCIL_Svc(5450181)_TxQThd(3083604),5,main]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         com.cisco.cti.ctios.util.QueueThread.GetQItem(QueueThread.java:152)
         com.cisco.cti.ctios.util.QueueThread.run(QueueThread.java:259)
    Thread[pool-2-thread-1,5,main]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         java.awt.Dialog.show(Unknown Source)
         javax.swing.JOptionPane.showOptionDialog(Unknown Source)
         javax.swing.JOptionPane.showMessageDialog(Unknown Source)
         javax.swing.JOptionPane.showMessageDialog(Unknown Source)
         in.co.netsol.telecom.desktop.DesktopMainPanel$3.run(DesktopMainPanel.java:1871)
         java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
         java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thread[Signal Dispatcher,9,system]
    Thread[Reference Handler,10,system]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
    Thread[TimerQueue,5,javawsApplicationThreadGroup]
         java.lang.Object.wait(Native Method)
         javax.swing.TimerQueue.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thread[pool-1-thread-4,5,main]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         java.awt.EventQueue.invokeAndWait(Unknown Source)
         javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
         in.co.netsol.telecom.desktop.command.MakeAgentNotReadyCommand$EventAdapter$1.run(MakeAgentNotReadyCommand.java:146)
         java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
         java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thread[pool-1-thread-6,5,main]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         java.awt.EventQueue.invokeAndWait(Unknown Source)
         javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
         in.co.netsol.telecom.desktop.command.TransferCallCommand$EventAdapter$1.run(TransferCallCommand.java:136)
         java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
         java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thread[traceMsgQueueThread,5,main]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         com.sun.deploy.util.Trace$TraceMsgQueueChecker.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thread[pool-1-thread-3,5,main]
         java.lang.Object.wait(Native Method)
         java.lang.Object.wait(Unknown Source)
         java.awt.EventQueue.invokeAndWait(Unknown Source)
         javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
         in.co.netsol.telecom.desktop.command.EmergencyCommand$EventAdapter$1.run(EmergencyCommand.java:146)
         java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
         java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         java.lang.Thread.run(Unknown Source)
    Thanks & Regards,
    Pradeep Gupta

    Update to the latest version 1.5.0_06 available from:
    http://java.sun.com/j2se/1.5.0/download.jsp
    It is advisable to remove previous version(s) installations unless required otherwise for a specfic application.

  • JOptionPane.show* cannot be used in DropTargetListener

    Hi guys!
    I am doing a File Explorer using Drag and Drop. In the my own DropTargetListener class, it seems that i can't use JOptionPane.showMessageDialog, InputDialog and the likes. It hangs!!! The Dialog pops up correctly but the entire application hangs immediately.
    Why is it so?
    Totally stumped!!!!

    ooops...it is a regression bug in Java 1.4
    http://developer.java.sun.com/developer/bugParade/bugs/4623377.html
    The J2SE 1.4.1 Beta Platform shows this bug as fixed in its list of
    fixed bugs.
    http://java.sun.com/j2se/1.4.1/fixedbugs/141-beta.html

  • Problem with Enter key and JOptionPane in 1.4

    Hi,
    I had a problem with an application I was working on.
    In this application, pressing [Enter] anywhere within the focused window would submit the information entered into the form that was contained within the frame.
    The application would then try to validate the data. If it was found to be invalid, it would pop up a JOptionPane informing the user of that fact.
    By default, pressing [Enter] when a JOptionPane is up will activate the focused button (in most cases, the [OK] button) thus dismissing the dialog.
    In JDK 1.3 this worked fine. But in JDK 1.4, this has the result of dismissing the dialog and opping it up again. This is because the [Enter] key still works on the frame behind the JOptionPane and thus tries to validate it again, which results in another invalid dialog msg popping up.
    The only way to get out is to use the mouse or the Esc key.
    Now, in the application I put in a workaround that I was not very happy with. So, to make sure it wasn't the application itself, I created a test which demonstrates that it still misbehaves.
    Here it is.
    import java.awt.Container;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyEvent;
    import javax.swing.AbstractAction;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JTextField;
    import javax.swing.KeyStroke;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    import javax.swing.WindowConstants;
    * @author avromf
    public class FocusProblemTest extends AbstractAction
         private static JFrame frame;
         public FocusProblemTest()
              super();
              putValue(NAME, "Test");
         public void actionPerformed(ActionEvent e)
              JOptionPane.showMessageDialog(frame, "This is a test.");
         public static void main(String[] args)
              FocusProblemTest action= new FocusProblemTest();
              try
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch (Exception e)
                   e.printStackTrace();
              frame= new JFrame("Test");
              frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
              Container contents= frame.getContentPane();
              contents.setLayout(new FlowLayout());
              JTextField field= new JTextField("Test");
              field.setColumns(30);
              JButton  button= new JButton(action);
              KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);
              button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(enterKey, "test");
              button.getActionMap().put("test", action);
              contents.add(field);
              contents.add(button);
              frame.pack();
              frame.setVisible(true);
    }Does anyone have any solution to this problem?

    I know that focus management has changed alot.
    Based on my experimentation a while back, in 1.4 it still believes that the JFrame is the window in focus, even though a JOptionPane is currently in front of it (unless I misinterpreted what was going on). Thus, the frame seems to get the keyboard event and re-invoke the action.
    A.F.

  • How to change The Standard JOptionPane Icon?

    in this simple code
    i want to change the Standard JOptionPane icon to a different icon
    how could it be?
    thank you
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.WindowListener;
    import java.awt.event.WindowEvent;
    import javax.sound.sampled.*;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.ImageIcon;
    import javax.swing.Icon;
    import java.awt.event.*;
      public class MyFrame extends JFrame 
    JLabel label=new JLabel("Hello");
      MyInner inner;
          MyFrame ()
            setupGUI();
        private void setupGUI()
           JFrame f =new JFrame();
        //   f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
           f.setTitle("Window Event");
            f.setSize(550,350);
            f.setResizable(false);
            f.setLayout(new BorderLayout());
            f.add("Center",label);
            f.show(true);
             inner=new  MyInner();
             f.addWindowListener(inner);
                   class MyInner extends WindowAdapter
           public void windowClosing(WindowEvent ee)
                         Toolkit tool = Toolkit.getDefaultToolkit();
                  tool.beep();
                      JOptionPane.showMessageDialog(null, "Nice Work! " );
                      System.exit(0);
          public  static void main(String[]args)
             MyFrame frame=new MyFrame ();
    }

    For instance:
        class MyInner extends WindowAdapter
            public void windowClosing(WindowEvent ee)
                Toolkit tool = Toolkit.getDefaultToolkit();
                tool.beep();
                JOptionPane.showMessageDialog(null, "Nice Work! ");
                ImageIcon myImageIcon = new ImageIcon("myPic.jpg"); // needs proper path here
                JOptionPane.showMessageDialog(null, "Better Work!", "Dang, I'm smart!", JOptionPane.ERROR_MESSAGE, myImageIcon);
                System.exit(0);
        }

  • How do you change default java logo in JOptionPane?

    I want to know how do you change the icon(the java logo in the title bar) for the JOptionPane box. I am using a swing interface. I can change the icon of the main frame but not of the JOptionPane.
    for the main frame i have used:
         Toolkit kit = Toolkit.getDefaultToolkit();
         Image img = kit.getImage("mypicture.gif");
         setIconImage(img);
    Toolkit is part of java.awt package.
    thanks

    here was a discussions about that
    http://forum.java.sun.com/thread.jsp?thread=120724&forum=57&message=316526

  • 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.

Maybe you are looking for

  • Which is better Function modules or Include programs?

    Hi, I am working on an enhancement and it has lot of screens with a tree structure on the left. Now we are planning to have each screen to have its PAI/PBO and the processing logic to be in seperate include programs. However in our team we have debat

  • Young library is looking for it's way

    Good day! Two and a half years have past and I think I've done something good. I've written a library to draw notes (music text) on screen. Library is based on swing (it extends JPanel... and that's all ;D). I've made some applications with that libr

  • Memory Leak with cloneModelFromCastMember()?

    Hello Experts! I have been experiencing an apparent memory leak within Director 11 when using cloneModelFromCastMember(). I was making the assumption that calling resetWorld() on a w3D member onBeginSprite() would garbage collect any models previousl

  • ALE partner profile setup for diff. IDOC extension

    Hi, We have three extensions of IDOC type HRMD_A06 and message type HRMD_A. In one of the extensions segment IT0002 is extended. In the partner profile extension is not specified. Due to this when the IDOC is generated Custom segment is not getting p

  • In Photoshop CS6, can you make the tab background go away?

    Is it possible in Photoshop CS6, to make the tab background go away? I find the background box that you need to work in, gets in my way. I cant see the finder/desktop underneith it like I could in CS5. Any way to change this? Thanks.