Should swing JFrame - I use threads or JDialogBox (or both!)?

Hello

I create a game in which several pieces may be on a site, and when you click on this square, I want a pop up window and allow the user to select from a list of parts.
The list of the selected pieces would return to the main program when the window is closed. When the window is opened, I would like to suspend the execution of the program.


So, copy the following code essentially illustrates the basics of my dilemma.
public class JBegin {
     public static void main(String[] args){
          customFrame newFrame= new customFrame(0);
     }
}
(code}
to import java.awt.Dimension;
import java.awt.event.MouseEvent;
java.awt.event.MouseListener import;

to import javax.swing.JFrame;


public class customFrame extends JFrame implements {MouseListener
int x = 0, y = 2, z;
public customFrame (int layer) {}
z = + 1 layer.
addMouseListener (this);
this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
this.setVisible (true);
this.setSize (New Dimension (1000, 1000));
}
@Override
{} public void mouseClicked (MouseEvent arg0)
TODO self-generating method stub
subset of customFrame = new customFrame (z);
freeze the previous window
wait customFrame close
get the values of subset.
x = y * 2 + z;
}

@Override
{} public void mouseEntered (MouseEvent arg0)
TODO self-generating method stub

}

@Override
{} public void mouseExited (MouseEvent arg0)
TODO self-generating method stub

}

@Override
{} public void mousePressed (MouseEvent arg0)
TODO self-generating method stub

}

@Override
{} public void mouseReleased (MouseEvent arg0)
TODO self-generating method stub

}

}
In the customFrame class, after the mouse button has been clicked, I want the code to wait for the new customFrame window to be closed before evaluating the equation.

I've done some reading, and I've heard that JDialog will accomplish most things a JFrame will (Though I haven't been able to find any tutorials on how to paint in JDialog).  I also may be hesitant because I have some classes which are configured wonderfully for a JFrame.

In any case, would threads or a JDialog box be a more appropriate way to solve this problem?  And if it is the JDialog option, do you know of a good JDialog painting tutorial (as, obviously, I've been having trouble finding one)?  

Thanks for all your time and advice                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

Thus, it seems that JDialog is not slow down the progression of the code.

Yes, he does, that's why I suggested it. Of course he could help if I spelled "modal" OK, if you could watch the API to see what method you use to define a modal dialog box.

You can also use a JOptionPane, which simply creates a JDialog formatted for you.

The choice is yours.

Tags: Java

Similar Questions

Maybe you are looking for

  • How to block offered ads that appear on the blank page?

    I put not to remember the history and delete cookies when you close Firefox. When I restart Firefox the white page is filled with advertising.

  • My Firefox is empty

    When I click on the shortcut, my opens Firefox with anything else that the top bar with the logo of Firefox and the close, minimize and resize buttons. I don't then right-click, use the commands Alt + (key) or Ctrl + (key) orders. I have no address b

  • HP 14-d037TU HDMI and VGA does not not for WIN7 64 bit

    Hello I came across another issue I solved all the problems of driver for laptop HP 14-d037TU. However, the HDMI and VGA is not working. Help, please. PCI\VEN_8086 & DEV_0F31 & SUBSYS_218D103C & REV_0APCI\VEN_8086 & DEV_0F31 & SUBSYS_218D103CPCI\VEN_

  • HP 240 G4 - drivers HP does not

    Hello You have a HP 240 G4 Notebook PC here, P/N: K9Y49LT Try a clean installation on an SSD. I have 7 unknown devices. Several drivers on the HP site do not work.All Intel drivers give me an error message:"This platform is not supported.or:"This sys

  • Satellite C850-1j1 not boot not

    my PC laptop Satellite C850-1j1 unbootable.He arrived after the partition is changed. Displays an error screen telling me that the computer must be repaired with recoverymedia. I have a work hirens boot cd and usb (tested on other COMP.), but the lap