Modal JOptionPane

Hi all,
Is there a way to keep a modal JOptionPane always on top...of all windows, even if a user opens a new gui window on top of the window the JOptionPane is "modaled" to?
I've searched some of the archives and found a solution or two that wasn't successful, but can't seem to find enough info to decide it is or is not possible.

what do you set as the first argument of
showXXXDialog() ?
It should be a component of the frame, e.g.
frame.getContentPane().Unless, of course you don't want it to have a parent frame and pass 'null' which will create a new frame in the center of the screen that contains the JOptionPane.
Brion Swanson

Similar Messages

  • JFrame displays without its components or settings (please help)

    On clicking a button in an app, due to computational time required, I need to have a message popup that says 'Please Wait', which vanishes on end of needed computation. For this, I have a small working class MsgDiag that simply displays a non-modal titled JFrame showing a message string in a JLabel and an 'ok' in a JButton. This works fine when invoked directly via its own main method as a standalone, but when called from that other application(also a extended JFrame) via button click, it just brings up a blank grey untitled JFrame without the components (JLabel and JButton) or the background color! It does stay up for the required duration and vanishes on disposing its JFrame as expected but why blank w/o components or settings ?
    I also find that though the JFrame component comes up blank grey, if during the computation portion in calling application, if any info/errors are popped up via direct call to a JOptionPane().showMessageDialog(JFrame(),msgString, titleString, msgType), then along with that modal popup (from JOptionPane), the grey JFrame gets correctly drawn with components and background !
    Does this provide any hints ? Since MsgDiag works ok by itself I am puzzled.
    I also tried putting basic code from MsgDiag (creating JFrame, adding its components, setting it visible etc) into the other app directly but same grey blank frame results. Had there been a non-modal JOptionPane I could have tried using it. I use JRE 1.4.2

    Per your suggestion, I tried putting computational part in a different thread. Also tried putting the thread priority for computational thread to lowest.
    In other approach, also tried putting the GUI popup (frame2) in a separate thread with highest priority while lowest priority computational thread executed. But neither approach worked. Still shows frame2 as blank w/o background or components inside while low priority computational thread finished, when frame2 gets disposed as instructed.
    In 1st approach, also tried adding validate() following setSize() as some other posts have suggested but that did not change anything. Any other pointers ?

  • Question abou JDialog

    I used JOptionPane to create a modal Dialog. However, I want to create a non-modal Dialog by JDialog. After reading the swing tutorial, I am still very confused. Would you please tell me where I can find sample code?
    thanks...

    By default JOptionPane has modality...
    If u want a non modal JOptionPane,then there is no way
    except u create ur own using JDialog.....
    Its easy to create a JDialog with a JTextField and 2 buttons.... :)

  • JOptionPane internal messages modality

    Hi,
    I was trying to workaround the fact that modal dialogs and option panes block the entire JVM and not only their parents, so I decided to give JOptionPane.showInternalMessageDialog a try using Java 5.0 (since the modality was broken in JDK 1.4.2_xx).
    If you give the sample below a try, you will notice that displaying an internal message in the primary frame will block the internal frames of both the primary and the secondary frames.
    Is there any way to disable this behavior and reduce the modality scope of the internal message to the desktop pane it belongs to?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class InternalOptionPane {
      public static void displayApplicationWindow(String title) {
        final JFrame appFrame = new JFrame(title);
        appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        final JDesktopPane desktop = new JDesktopPane();
        final JButton displayMessageBtn = new JButton("Display message");
        ActionListener displayInternalMessageAction = new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showInternalMessageDialog(displayMessageBtn,
              "Why am I blocking the internal frames in other desktop pane?",
              "Internal message", JOptionPane.PLAIN_MESSAGE);
        displayMessageBtn.addActionListener(displayInternalMessageAction);          
        JInternalFrame iFrame = new JInternalFrame("Internal Window");
        desktop.add(iFrame);
        Container iContent = iFrame.getContentPane();
        iContent.setLayout(new FlowLayout());
        iContent.add(displayMessageBtn);
        iFrame.setBounds(25, 25, 200, 100);
        iFrame.setVisible(true);
        Container content = appFrame.getContentPane();
        content.add(desktop, BorderLayout.CENTER);
        appFrame.setSize(500, 300);
        appFrame.setVisible(true);
      public static void main(String args[]) {
         displayApplicationWindow("Primary");
         displayApplicationWindow("Secondary");
    }Many Thanks
    Hani

    Hello Jarek,
    >> But when I run it from SQL Plus I see following error: …
    This API must run in the APEX context. You should use a privilege user, or the APEX owner (in this case you don’t need to change the curret_schema parameter). Try the following script as an example:
    declare
      l_ddl  varchar2(100);
    begin
       l_ddl := 'alter session set current_schema="APEX_030200"';
       EXECUTE IMMEDIATE (l_ddl);
       wwv_flow_api.set_security_group_id(apex_util.find_security_group_id('MyWorkspaceName'));
       wwv_flow_api.create_message (
        p_flow_id => '192',
        p_name => 'APEXIR_AGGREGATE',
        p_message_language => 'pl',
        p_message_text => 'Agregacja'
    end;If you are using an earlier version to 3.2, you should set the appropriate schema name to your version. Also, the ‘MyWorkspaceName’ should be replaced with your actual workspace name.
    Bear in mind that the relevant APEX meta data tables include a unique restraint, so you can’t run the script repeatedly, without deleting set messages.
    This is an unsupported action, so please take all the necessary precaution to avoid any problems, like BACKUP, BACKUP and BACKUP.
    >> In general it looks like security bug because I can run this procedure for other applications which do not exist in my workspace.
    This API was meant to be used by the APEX development team only, so maybe its code is not checking all malicious options out there. I’ll draw the attention of Joel, from the development team, to your claim. If it need fixing, I’m sure he will take care of it.
    Regards,
    Arie.
    ♦ Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    ♦ Forthcoming book about APEX: Oracle Application Express 3.2 – The Essentials and More

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

  • In Unix, main JFrame focus not regained after modal dialog exit.

    Hi all,
    I'm new to this forum so hopefully this is the right place to put this question.
    I have a relatively simple GUI application written in Java 6u20 that involves a main gui window (extends JFrame). Most of the file menu operations result in a modal dialog (either JFileChooser or JOptionPane) being presented to the user.
    The problem is that when running on Unix (HPUX), the process of changing focus to one of these modal dialogs occasionally results in a quick flash of the background terminal window (not necessarily that used to launch the Java), and the process of closing the modal dialogs (by any means, i.e. any dialog button or hitting esc) doesn't always return focus to the main extended JFrame object, sometimes it goes to the terminal window and sometimes just flashes the terminal window before returning to the main JFrame window.
    I think the problem is with the Unix window manager deciding that the main focus should be a terminal window, not my Java application, since the problem occurs in both directions (i.e. focus from main JFrame to modal dialog or vice versa).
    In most cases of JOptionPane, I DO specify that the main extended JFrame object is the parent.
    I've tried multiple things since the problem first occured, including multiple calls to a method which calls the following:
    .toFront();
    .requestFocus();
    .setAlwaysOnTop(true);
    .setVisible(true);
    ..on the main JFrame window (referred to as a public static object)...
    just before and after dialog display, and following selection of any button from the dialogs. This reduced the frequency of the problem, but it always tends to flash the terminal window if not return focus to it completely, and when it occurs (or starts to occur then gets worse) is apparently random! (which makes me think it's an OS issue)
    Any help appreciated thanks,
    Simon
    Self-contained compilable example below which has the same behaviour, but note that the problem DOESN'T occur running on Windows (XP) and that my actual program doesn't use auto-generated code generated by a guibuilder:
    * To change this template, choose Tools | Templates 
    * and open the template in the editor. 
    package example;  
    import javax.swing.JOptionPane;  
    * @author swg 
    public class Main {  
         * @param args the command line arguments 
        public static void main(String[] args) {  
            java.awt.EventQueue.invokeLater(new Runnable() {  
                public void run() {  
                    new NewJFrame().setVisible(true);  
    class NewJFrame extends javax.swing.JFrame {  
        /** Creates new form NewJFrame */ 
        public NewJFrame() {  
            initComponents();  
        /** This method is called from within the constructor to 
         * initialize the form. 
         * WARNING: Do NOT modify this code. The content of this method is 
         * always regenerated by the Form Editor. 
        @SuppressWarnings("unchecked")  
        // <editor-fold defaultstate="collapsed" desc="Generated Code">  
        private void initComponents() {  
            jMenuBar1 = new javax.swing.JMenuBar();  
            jMenu1 = new javax.swing.JMenu();  
            jMenuItem1 = new javax.swing.JMenuItem();  
            jMenu2 = new javax.swing.JMenu();  
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);  
            jMenu1.setText("File");  
            jMenuItem1.setText("jMenuItem1");  
            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {  
                public void actionPerformed(java.awt.event.ActionEvent evt) {  
                    jMenuItem1ActionPerformed(evt);  
            jMenu1.add(jMenuItem1);  
            jMenuBar1.add(jMenu1);  
            jMenu2.setText("Edit");  
            jMenuBar1.add(jMenu2);  
            setJMenuBar(jMenuBar1);  
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());  
            getContentPane().setLayout(layout);  
            layout.setHorizontalGroup(  
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
                .addGap(0, 400, Short.MAX_VALUE)  
            layout.setVerticalGroup(  
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
                .addGap(0, 279, Short.MAX_VALUE)  
            pack();  
        }// </editor-fold>  
        private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {  
            int result = JOptionPane.showConfirmDialog(this, "hello");  
        // Variables declaration - do not modify  
        private javax.swing.JMenu jMenu1;  
        private javax.swing.JMenu jMenu2;  
        private javax.swing.JMenuBar jMenuBar1;  
        private javax.swing.JMenuItem jMenuItem1;  
        // End of variables declaration  
    }

    It won't comfort you much, but I had similar problems on Solaris 10, and at the time we traked them down to a known bug [6262392|http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6262392]. The status of this latter is "Closed, will not fix", although it is not explained why...
    It's probably because the entry is itself related to another, more general, bug [6888200|http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=b6eea0fca217effffffffe82413c8a9fce16?bug_id=6888200], which is still open.
    So it is unclear whether this problem will be worked upon (I suspect that yes) and when (I suspect that... not too soon, as it's been dormant for several years!).
    None of our attempts (+toFront(...)+ etc...) solved the issue either, and they only moderately lowered the frequency of occurrence.
    I left the project since then, but I was said that the workaround mentioned in the first bug entry (see comments) doesn't work, whereas switching to Java Desktop instead of CDE reduced the frequency of the issues (without fixing them completely either) - I don't know whether it's an option on HPUX.
    Edited by: jduprez on Jul 9, 2010 11:29 AM

  • How to make a dalog process custom events when blocked by modal dialog

    Hi,
    I would like to understand the way modal dialogs block other dialogs so that I can properly solve an issue I'm having with two modal dialogs, one blocking the other.
    I have an application, netbeans platform based, that opens a JDialog, NewDiskDlg, with it's modal property set to true. This dialog is responsible for starting a thread that will process a given number of files, from time to time, depending on some conditions, this thread will send events to the NewDiskDlg.
    When this thread is started, the NewDiskDlg creates a new JDialog, also with the modal property set to true. Both dialogs have the same parent, the main window. And this works as I expected, the second dialog, ActiveScanningDlg, opens on top of the NewDiskDlg and, until the thread stops, the dialog stays visible.
    When the thread stops an event is sent to this two dialogs signaling that the job has been completed, and here is my problem. The second dialog, the one that is visible when the event arrives, receives the event and executes the dispose() method, releasing control to the NewDiskDlg in the back, but the NewDiskDlg does not receive the event and does not process it correctly.
    I understand the no input can be sent to a blocked window, but does that include calling upon the window's methods?
    I've been looking for some help on this but my search terms are not good enough to provide me with any useful information. I've also read the topic on the focus system that is present in the Java Tutorial but I feel that that is not what I should be looking at.
    The following code is a snippet of the important parts that I described:
    NewDiskDlg has the following methods to process the events
        public void readingStarted(ReadingEvent evt) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    scanningDlg.showCentered();
        public void readingFile(ReadingEvent evt) {
            //DO NOTHING
        public void readingStopped(ReadingEvent evt) {
            Lookup.getDefault().lookup(MediaReader.class).removeListener(this);
            if (!showAgain) {
                dispose();
        public void readingAborted(ReadingEvent evt) {
            JOptionPane.showMessageDialog(this, "", "", JOptionPane.ERROR_MESSAGE);//TODO: i18n on the error messagens
            Lookup.getDefault().lookup(MediaReader.class).removeListener(this);
        }ActiveScanningDlg processes the events like this:
        public void readingStarted(ReadingEvent evt) {
            //DO NOTHING
        public void readingFile(ReadingEvent evt) {
            jpbReadingProgress.setString(evt.getCurrentFileName());
        public void readingStopped(ReadingEvent evt) {
            Lookup.getDefault().lookup(MediaReader.class).removeListener(this);
            dispose();
        public void readingAborted(ReadingEvent evt) {
            readingStopped(evt);
        }This is an example on how the events are sent:
        private void fireReadingFile(ReadingEvent evt) {
            for (ReadingListener l : listeners) {
                l.readingFile(evt);
        }

    Hi,
    You have to check the Tolerance limits set for the following tolerance keys. In case if any where the limit is breached the systems blocks the Invoice as 'R - Invoice verification'. Please check the limits set for all these keys.
    AP - item amount variance (if you have activated the item check)
    DQ and DW - for Quantity variance
    PP - price variance with the order price
    ST - date variance
    VP - Moving average price variance
    Regards,
    Kathir

  • JDialog Non Modal....Default button remains

    I've created a non modal JDialog
    By doing the following
    1. Creating an object of JOptionPane(message, JOptionPane.ERROR_MESSAGE)
    2. Adding the JOptionPane object to the ContentPane
    3. Creating a button
    4. Adding button("End Application") to ContentPane
    5. Adding listeners to window and button
    The result is a dialog
    Message
    ICON "OK" Button...............................NOT REQUIRED
    "End Application" Button
    I don't require the "OK" Button. Is there a way of removing this button. I need the dialog box to be modal so can't use showMessageDialog, rename "Ok" button to "End Application" etc.
    Should I be taking a different approach ie Not adding JOptionPane to JDialog??
    If the above isn't possible. Do you know where I can find the default error gif on error dialog boxes?
    Kind regards,
    Jean

    Get the error icon with UIMananger.getIcon("OptionPane.errorIcon"). It might throw exceptions while painting because it's expecting to be painting in a JOptionPane. Just catch and ignore the exceptions and it will paint alright.

  • Issues opening pdf in a modal jdialog

    Hi guys,
    I've a strange issue, I can't solve it.
    I'm newbie of java swing and this is a very difficult issue.
    I've a jdialog modal. In this jDialog I've a button, clicking on it a pdf is generated with itext.
    I observed that:
    -if I try to generate pdf from a frame, pdf is shown over the frame.
    -if I try to generate pdf from a jdialog swing(that's case I need) pdf is shown below jdialog...so I can't see pdf without closing jdialog and it's not good.
    How can I proceed in the second case?
    Thanks

    hi,
    thanks for your reply...I try to addo more detail.
    I have a modal jdialog.
    In it I have a button, clicking on it is called a method to create a pdf with itext.
    Here a snippet of code
    try {
                  Document document = new Document(PageSize.A4);
                   PdfWriter.getInstance(document, new FileOutputStream(FILE));
                   document.open();
                            create(document);
                   document.close();
                            String[] command = new String[3];
                   command [0] = "cmd.exe";
                   command [1] = "/C";
                   command [2] = "\"" + FILE+ "\"";
                            Runtime.getRuntime().exec(command );
              } catch (Exception e) {
                   e.printStackTrace();
                            JOptionPane.showMessageDialog(null, "Si è verificato il seguente errore: "+e.getMessage(), "Errore stampa pdf", JOptionPane.ERROR);
                            return;
              }Following this way pdf is opened but it's shown under the modal jdialog that called it.
    So for watching it I need to close modal jdialog.
    How can I run pdf to make it OVER a modal jdialog?
    Thanks,
    Regards

  • JOptionPane show Message Dialog always on top found a Solution

    just thought of a solution for the age old java problem with message boxes / dialogs / input .
    It's funny when you google it you'll find like a million people asking for a solution but none or very few that gives an answer that works.
    this is probly not a new solution but i came up with this yesterday and thought i would "share".
    dunno why the java developers hasnt made a always on top function for this since there seems to be a very high demand for it.
    this hax will hopefully work at all times.
    hope google will find this thread, i searched for a solution yesterday and found none? which is surprising and im a pro googler too.
    import javax.swing.*;
    public class main{
         public static void main(String args[]){
              JFrame j=new JFrame();
              j.setAlwaysOnTop(true);
              j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              j.setVisible(true);
              j.setVisible(false);
              JOptionPane.showMessageDialog(j,"hi");
              System.exit(0);
    }

    I didn't realize it was an "age old problem." The JOptionPane's showXXX methods just show an ordinary modal dialog. If you want to set the alwaysOnTop property of said dialog then you just need to obtain a reference and call the method in question.
    JOptionPane op = new JOptionPane("hi",JOptionPane.INFORMATION_MESSAGE);
    JDialog dialog = op.createDialog("Message Dialog");
    dialog.setAlwaysOnTop(true); //<-- this line
    dialog.setModal(true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setVisible(true);No need for an intermediate frame.

  • JOptionPane.showOptionDailog Hangs Application

    Hi,
    JOptionPane.showOptionDailog hangs application(In JDK1.3.1) when used in Threads..
    Is there anyway to get rid of this..
    Thanks,
    Sridhar.

    So, as I understand you have following situation:
    1. You have the GUI event thread (you did not created it explicte - once you did shown first component it was created by Swing)
    2. You have, lets call it worker thread which does some work in background and can detect, that you must ask user for
    password. This thread also does something, what you don't wan't to stop while user types password.
    The critical situation is:
    - worker thread detecects, that should ask for password and displays modal JDialog. This way the only active GUI part is this dialog and thread blocks, waiting (since invokeAndWait()) for user to finish typing - this way it can't process what it should.
    For me the solution is:
    - make sure, your worker thread can work even if password is not set - this way it can work while user is typing. It should be able to send password request, return to work and recive password;
    - instead of using JOptionPane subclass JDialog:
    class CPswPrompt extends JDialog
              private YourWorkerThreadClass worker;
       public CPswPrompt(YourWorkerThreadClass worker, Frame owner)
             super(owner);
             this.worker =worker;
           JButton ok = ...
           ok.addActionListener(new Ac...
                       public void actionPerformed (ActionEvent e)
                                worker.setYourUserPassword(....); //<<--- here you will pass pasword to worker thread.
    };The show it with invokeLater.
    if you make this dialog non-modal, you will have your GUI responsive and thread working.

  • Focus Problem -- Two Non Modal Dialogs

    Hi ,
    In my applet, when user does something which is not allowed, I display an error message box (JOptionPane dialog - modal).
    There is another dialog box (non modal) that user
    can open to view search results and put it aside the
    applet window to do some parallel work.
    Now when error message dialog appears, the search
    dialog box also pops up even if the user
    has put this behind the applet window (by clicking browser window or applet, the search dialog goes behind the window).
    Can you please let me know, how can I get rid
    of this search dialog (non-modal) popup. I mean
    search dialog should remain open but should not
    come infront (ie should not get focus) when modal
    error message dialog pops up.
    NOTE: I don't want to make search dialog
    a modal dialog.
    Thanx,
    [email protected]

    Thanks for the reply michael. I forgot to mention particularly during my post that i am facing this problem on Solaris system. Running the same application on windows is working fine. I can't make other non-modal dialogs visibility to false because they should be visible on the screen all the time throught out the application life cycle and making it visible/non-visible doesn't get sense in my application. Does anybody is facing the same problem with Solaris system? Plz help.
    Hitesh

  • Arbitary Modal dialog in JDeskTop MDI environment

    Why have Sun gone to such lengths to make it difficult to do your own model dialogs?
    JOptionPane with it's showInternalXXX methods hints that JDialogs in an MDI are unhealthy (even though I'm not sure why).
    Looking through the source for JOptionPane and JDialog shows that making your own JInternalWindow modal would be, at best, messy, at worst impossible.
    JOptionPane acually uses a reflection cheat to access a private method in Component to do the modal thing.
    Anyone know why this minefield has been built, and how best to get through?

    On the face of it, sure. And I've yet to have a problem using JDialog this way.
    What puzzles me, then, is why JOptionPane goes to the trouble of having all those showInternalXXXDialog methods, which when I check the code do their own thing as far a modality is concerned. I had a poke arround in the source of JOptionPane in an attempt to determine the point in having these two kinds of Dialog.
    On a previous occasion I've looked through JDialog in an attempt to understand how that implements modality. And it does it in rather a different way.
    In both cases it seems like Sun has gone out of their way to prevent us from doing our own thing.

  • Adding custom buttons to JOptionPane

    Hi,
    I need to add custom buttons to my showMessageDialogue boxes.
    I know that
    JOptionPane.showMessageDialog
    (null, "message body", "message title", JOptionPane.YES_NO_OPTION,
    JOptionPane.INFORMATION_MESSAGE);displays an information box with a 'Yes' and a 'No' button. But how do I include three or more custom buttons on such a box?
    For example, I want to display an information message box with buttons: 'Auto', 'Prompt' and 'Never'.
    What if I want to mix orthodox buttons, with my custom buttons? For example, putting 'Auto', 'Prompt' and 'Cancel' in one information message box?
    Thanks,
    Hasanka.

    Use the last method for showMessageDialog. The options[] paremeter can take an array of Strings and return to you which button was pressed (by index).
    showOptionDialog
    public static int showOptionDialog(Component parentComponent,
                                       Object message,
                                       String title,
                                       int optionType,
                                       int messageType,
                                       Icon icon,
                                       Object[] options,
                                       Object initialValue)Brings up a modal dialog with a specified icon, where the initial choice is dermined by the initialValue parameter and the number of choices is determined by the optionType parameter.
    If optionType is YES_NO_OPTION, or YES_NO_CANCEL_OPTION and the options parameter is null, then the options are supplied by the Look and Feel.
    The messageType parameter is primarily used to supply a default icon from the Look and Feel.
    Parameters:
    parentComponent - determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
    message - the Object to display
    title - the title string for the dialog
    optionType - an integer designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
    messageType - an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
    icon - the icon to display in the dialog
    options - an array of objects indicating the possible choices the user can make; if the objects are components, they are rendered properly; non-String objects are rendered using their toString methods; if this parameter is null, the options are determined by the Look and Feel.
    initialValue - the object that represents the default selection for the dialog
    Returns:
    an integer indicating the option chosen by the user, or CLOSED_OPTION if the user closed the Dialog

  • Modality bug

    has anyone else had problems with modality using the bridge. it totally fouls up for me....
    i have tried two ways if i do this...
    public class MyFrame extends JFrame implements Serializable{
      public MyFrame(){
        super("Test One");
        setSize(20,20);
      public int showMenu(){
        setVisible(true);
        int toReturn = JOptionPane.showConfirmDialog(this,"Click any button");// goes into modal mode here and locks up
      setVisible(false);
      return toReturn;
    }and then from vba do this...
    iVal = myBean.showMenu
    the dialog shows up and word is waiting for it but all the Java components including the confirm dialog are also locked up so you can't do anything.
    the only way to get back is to kill word or whatever app is running.
    second example...
    public class MyDialogFrame extends JFrame implements Serializable{
      private JDialog dialog;
      private int rc;
      public MYDialogFrame(){
        super("Test Two");
        setSize(20,20);
        dialog = new JDialog(this,"Actual Menu",true);
      public int showMenu(){
        dialog.show();//goes into modal mode here and locks up
        return rc;
    }then again from vba
    and then from vba do this...
    iValTwo = myBean.showMenu
    i can see the dialog but everything is locked up and i can't do anything with it.
    again have to kill the app.
    i can always reproduce this bug in vba in office 97.
    just wondering if anyone else has had this problem and better still does anyone have a workaround?
    if the bridge gets put back into to 1.4.X or whatever i will report this as a bug there but i'm not sure of the point right now.

    I've had similar problems myself, but I think you can work around it by supplying a (suitably wrapped) reference to the parent (VB or C) frame. The following fragment is from a java.awt.Panel subclass that I have placed in the activeX container (i.e. it is the main bean that I have run through the packager):
         Component c = getParent();
         while (c != null) {
              if (c instanceof Frame) {
                   Dialog d = new Dialog((Frame) c, true);
                   // Set up ui controls!
                   d.addWindowListener(this);
                   d.setVisible(true);
                   break;
              } else {
                   c = c.getParent();
         }While the 'Frame' that you can access by traversing up the getParent() hierarchy is not a normal frame (its class is sun.beans.ole.OleEmbeddedFrame), it is fine for modality purposes.

Maybe you are looking for

  • Open Item Clearing IDOC

    Hello, Does anyone know if there's an idoc that can clear open items as you would in a t-code like F-32?  I know of the LOCKBX FINSTA01 idoc, but we don't need the lockbox piece and just want to do a post with clearing. Appreciate the help, Kevin

  • I need a text field in a table cell to expand dynamically

    When I say expand I mean the whole cell has to grow as the content is entered into it, not just have a scroll bar present to contain the content, every new line should expand the table cell vertically. I've been looking all over and I can't seem to f

  • Collaboration Server Discussion Forums

    Hi, Need to know if the below mentioned are possible using the Collaboration Server(Collaboration_4-2_win). 1. Is personalization possible in discussions? i.e. Let us say we have a 3 members X, Y and Z discussing on the same topic. X initiates the di

  • Downloaded Version vs Box Version

    I recently downloaded the trial version of Lightroom 1.1 and decided to purchase a license and ordered a boxed version. My question: is the boxed version and different fron the version I downloaded from Adobe Web site thus should I delete the downloa

  • Update not installing

    For Illustrator the download gets the the 'finishing stage' and for photoshop the download is stuck at 'waiting...' Its been like this for weeks and i'm sick of it I just want to update my programs. Not to mention i have to post to this stupid forum