Math.abs((fromLoc.y)-(toLoc.y))<=150 &&
Math.abs((fromLoc.z)-(toLoc.z))<=150) {
//Cover Screen not needed
} else {
//attach cover screen
final MainFrame mainFrame = JmeClientMain.getFrame();
final Canvas canvas = mainFrame.getCanvas();
final CoverScreen coverScreenPanel = new CoverScreen(csd,canvas.getSize());
try {
//show cover screen in JDialog over the canvas panel
SwingUtilities.invokeLater(new Runnable() {
public void run() {
dialog = new JDialog(mainFrame.getFrame(), "Child", false);
coverScreenPanel.setPreferredSize(canvas.getSize());
dialog.setSize(canvas.getSize().width
,canvas.getSize().height);
dialog.setLocation(canvas.getLocationOnScreen().x
,canvas.getLocationOnScreen().y);
JButton button = new JButton("Button");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
mainFrame.getFrame().addComponentListener(new ComponentAdapter() {
private void doChange() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (dialog != null && dialog.isVisible()) {
Component cs = dialog.getComponent(0);
Canvas canvas = mainFrame.getCanvas();
cs.setPreferredSize(canvas.getSize());
dialog.setSize(canvas.getSize().width, canvas.getSize().height);
dialog.setLocation(canvas.getLocationOnScreen().x, canvas.getLocationOnScreen().y);
dialog.pack();
dialog.setVisible(true);