0

I am calling ABC jINternalFrame from XYZ jInternalFrame in SWING.

But When I call ABC I am losing XYZcontrol

What I want is

-On XYZ user selects option to load product data
-IF mismatch found XYZ calls ABC
-In ABC -user correct mismatch and closes ABC frame
Now I want my program should continue from where it called ABC

Currently It calls ABC and XYZ get executed How I can achieve this ? And I am using below code

if (frmUpdateData == null || frmUpdateData.isClosed()){ 
  frmUpdateData = new FrmUpdateData(); 
  JDesktopPane desktopPane = getDesktopPane(); 
  desktopPane.add(frmUpdateData); 
  frmUpdateData.setVisible(true); 
  frmUpdateData.setLocation(this.getWidth()/2- frmUpdateData.getWidth()/2, this.getHeight()/2-frmUpdateData.getHeight()/2); 
}
  • 1
    I'm not 100% clear on what you're asking -- please clarify the question for us, but I think that [this question](http://stackoverflow.com/questions/14083517/joptionpane-issue-using-internal-dialog) may be a duplicate, and that you want to use a `JOptionPane.showInternalInputDialog` here. – Hovercraft Full Of Eels Oct 04 '16 at 12:21

1 Answers1

-1

You show use a Modal dialog:

final JDialog frame = new JDialog(parentFrame, frameTitle, true);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);

When you show a modal dialog, the code that called the modal, is waiting for modal dialog to be closed to continue execution. It is like alert in JavaScript.

If you dont wana use JDialog, you can try this:

    JInternalFrame frmUpdateData = null;
    frmUpdateData = new JInternalFrame("Test", true, true);
    frmUpdateData.setBounds(0, 0, 200, 200);
    JDesktopPane desktopPane = new JDesktopPane();
    desktopPane.setBounds(0, 0, 600, 600);
    desktopPane.add(frmUpdateData);
    desktopPane.setVisible(true);
    frmUpdateData.setVisible(true);
    JFrame frame = new JFrame();
    frame.setBounds(0, 0, 600, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(desktopPane);
    frame.setVisible(true);
    while (frmUpdateData != null && !frmUpdateData.isClosed()) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    JOptionPane.showMessageDialog(null, "Done");

Reference: Stackoverflow

Community
  • 1
  • 1
Edgard Leal
  • 2,592
  • 26
  • 30
  • Hi @Edgard-Leal I am using this code currently how shold I chnage it to use modal dialog to a jinternal frame `code` if (frmUpdateData == null || frmUpdateData.isClosed()){ frmUpdateData = new FrmUpdateData(); JDesktopPane desktopPane = getDesktopPane(); desktopPane.add(frmUpdateData); frmUpdateData.setVisible(true); frmUpdateData.setLocation(this.getWidth()/2- frmUpdateData.getWidth()/2, this.getHeight()/2-frmUpdateData.getHeight()/2); } `code` – Rajesh Mhatre Oct 04 '16 at 12:51