2 Commits 3af096cd0d ... 9839805b85

Author SHA1 Message Date
  I. Dix 9839805b85 fixes #72: fixed positioning for JOption/JMessagePanes + 1 forgotten popUp 6 years ago
  I. Dix 07f8506d73 #72: fixed positioning for PopUps (open: JOption/JMessagePanes) 6 years ago

+ 16 - 25
src/ui/view/AboutUsPopUp.java

@@ -1,25 +1,16 @@
 package ui.view;
 
-import java.awt.BorderLayout;
-import java.awt.Font;
-import java.awt.Image;
-import java.awt.Dimension;
-
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
+import javax.swing.*;
+import java.awt.*;
 
 /**
  * AboutUs Pop Up Window.
- * 
+ *
  * @author Gruppe14
  */
 public class AboutUsPopUp extends JFrame {
-	/**
-	 * Serial.
+    /**
+     * Serial.
      */
     private static final long serialVersionUID = 1L;
     private final JPanel contentPanel = new JPanel();
@@ -40,7 +31,7 @@ public class AboutUsPopUp extends JFrame {
     /**
      * Constructor
      */
-    public AboutUsPopUp() {
+    public AboutUsPopUp(JFrame parentFrame) {
         super(Languages.getLanguage()[14]);
 
         // Set fonts
@@ -62,34 +53,34 @@ public class AboutUsPopUp extends JFrame {
         contentPanel3.setLayout(new BoxLayout(contentPanel3, BoxLayout.Y_AXIS));
 
         this.setIconImage(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
-                          .getScaledInstance(30, 30, Image.SCALE_SMOOTH));
+                .getScaledInstance(30, 30, Image.SCALE_SMOOTH));
         setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
         setBounds(100, 100, 500, 800);
-        setLocationRelativeTo(this.getParent());
+        setLocationRelativeTo(parentFrame);
 
-        contentPanel.add(Box.createRigidArea(new Dimension(0,15)));
+        contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
         contentPanel.add(titel);
-        contentPanel.add(Box.createRigidArea(new Dimension(0,15)));
+        contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
         contentPanel.add(description);
-        contentPanel.add(Box.createRigidArea(new Dimension(0,60)));
+        contentPanel.add(Box.createRigidArea(new Dimension(0, 60)));
         getContentPane().add(contentPanel, BorderLayout.NORTH);
 
         contentPanel2.add(h1);
         contentPanel2.add(namesManagement);
-        contentPanel2.add(Box.createRigidArea(new Dimension(0,50)));
+        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
         contentPanel2.add(h2);
         contentPanel2.add(namesDevelopers);
-        contentPanel2.add(Box.createRigidArea(new Dimension(0,50)));
+        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
         contentPanel2.add(h3);
         contentPanel2.add(namesDocumentation);
-        contentPanel2.add(Box.createRigidArea(new Dimension(0,50)));
+        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
         contentPanel2.add(h4);
         contentPanel2.add(namesCollaborators);
-        contentPanel2.add(Box.createRigidArea(new Dimension(0,50)));
+        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
         contentPanel2.add(credits);
         getContentPane().add(contentPanel2, BorderLayout.CENTER);
 
-        contentPanel3.add(Box.createRigidArea(new Dimension(0,50)));
+        contentPanel3.add(Box.createRigidArea(new Dimension(0, 50)));
         //contentPanel3.add(namesDevelopers);
         getContentPane().add(contentPanel3, BorderLayout.SOUTH);
     }

+ 3 - 3
src/ui/view/AddElementPopUp.java

@@ -48,13 +48,13 @@ public class AddElementPopUp extends JDialog {
 	/**
 	 * Create the dialog.
 	 */
-    AddElementPopUp() {
-        super((java.awt.Frame) null, true);
+	AddElementPopUp(JFrame parentFrame) {
+		super((java.awt.Frame) null, true);
 		this.setIconImage(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
 				.getScaledInstance(30, 30, Image.SCALE_SMOOTH));
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
 		setBounds(100, 100, 400, 190);
-		setLocationRelativeTo(this.getParent());
+		setLocationRelativeTo(parentFrame);
 		getContentPane().setLayout(new BorderLayout());
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
 		getContentPane().add(contentPanel, BorderLayout.CENTER);

+ 6 - 6
src/ui/view/AddObjectPopUp.java

@@ -68,14 +68,14 @@ public class AddObjectPopUp extends JDialog {
 	 * @param cat
 	 *            the categorie
 	 */
-	AddObjectPopUp(boolean edit, AbstractCpsObject obj, String cat) {
-		toEdit = obj;
+    AddObjectPopUp(boolean edit, AbstractCpsObject obj, String cat, JFrame parentFrame) {
+        toEdit = obj;
 		editState = edit;
 		this.setIconImage(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
 				.getScaledInstance(30, 30, Image.SCALE_SMOOTH));
 		setBounds(100, 100, 450, 342);
-		setLocationRelativeTo(this.getParent());
-		getContentPane().setLayout(new BorderLayout());
+        setLocationRelativeTo(parentFrame);
+        getContentPane().setLayout(new BorderLayout());
 		JPanel contentPanel = new JPanel();
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
@@ -165,8 +165,8 @@ public class AddObjectPopUp extends JDialog {
 		{
 			JButton btnAddDefaultElement = new JButton(Languages.getLanguage()[61]);
 			btnAddDefaultElement.addActionListener(actionEvent -> {
-				addElement = new AddElementPopUp();
-				addElement.setActualCps(toEdit);
+                addElement = new AddElementPopUp(parentFrame);
+                addElement.setActualCps(toEdit);
 				addElement.setVisible(true);
 				HolonElement hl = addElement.getElement();
 				hl.setSaving(new Pair<>(givenCategory, objectName.getText()));

+ 15 - 23
src/ui/view/AlgorithmMenu.java

@@ -1,6 +1,13 @@
 package ui.view;
 
-import java.awt.Color;
+import api.CpsAlgorithm;
+import ui.controller.Control;
+import ui.model.Model;
+
+import javax.swing.*;
+import javax.tools.JavaCompiler;
+import javax.tools.ToolProvider;
+import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.io.BufferedReader;
@@ -10,18 +17,6 @@ import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.HashMap;
 
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-
-import api.CpsAlgorithm;
-import ui.controller.Control;
-import ui.model.Model;
-
 /**
  * This Class represents the Menu, where you can select the Algorithms.
  * 
@@ -32,15 +27,13 @@ public class AlgorithmMenu extends JMenu {
 	private static final long serialVersionUID = 1L;
 
 	JMenuItem algoFolderButton = new JMenuItem("Select Algorithm Folder");
-	private JMenu mnSelectAlgorithm = new JMenu("Select Algorithm");
-	private HashMap<String, File> algosHash = new HashMap<>();
-	private JMenuItem noneItem = new JMenuItem("none");
-
 	// root Directory
 	File root = null;
-
 	Model model;
 	Control controller;
+    private JMenu mnSelectAlgorithm = new JMenu("Select Algorithm");
+    private HashMap<String, File> algosHash = new HashMap<>();
+    private JMenuItem noneItem = new JMenuItem("none");
 
 	/**
 	 * Constructor.
@@ -50,8 +43,8 @@ public class AlgorithmMenu extends JMenu {
 	 * @param cont
 	 *            the Controller
 	 */
-	public AlgorithmMenu(Model mod, Control cont) {
-		super();
+    public AlgorithmMenu(Model mod, Control cont, GUI parentGui) {
+        super();
 		// Init Stuff
 		this.model = mod;
 		this.controller = cont;
@@ -67,12 +60,11 @@ public class AlgorithmMenu extends JMenu {
 
 			private void menuSetFolderActionPerformed(java.awt.event.ActionEvent evt) {
 				JFileChooser fileChooser = new JFileChooser();
-				JFrame test = new JFrame();
 				fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
 				fileChooser.setAcceptAllFileFilterUsed(false);
 
-				if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
-					// empty everything and reset the selected algorithm
+                if (fileChooser.showOpenDialog(parentGui.getFrmCyberPhysical()) == JFileChooser.APPROVE_OPTION) {
+                    // empty everything and reset the selected algorithm
 					controller.setAlgorithm(null);
 					mnSelectAlgorithm.removeAll();
 					mnSelectAlgorithm.add(noneItem);

+ 20 - 45
src/ui/view/BackgroundPopUp.java

@@ -1,80 +1,55 @@
 package ui.view;
 
-import javax.swing.JDialog;
-import javax.swing.JFileChooser;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.ButtonGroup;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-
 import classes.CpsUpperNode;
 import ui.controller.Control;
 import ui.model.Model;
 
+import javax.swing.*;
+import javax.swing.filechooser.FileNameExtensionFilter;
+import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.awt.BorderLayout;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JRadioButton;
-import javax.swing.SwingConstants;
-import java.awt.GridLayout;
-import java.awt.Image;
-import java.awt.Color;
-import java.awt.FlowLayout;
+import java.io.*;
 
 /**
  * Popup for setting the Background Image for the current View.
  **/
 public class BackgroundPopUp extends JDialog {
 
-	/**
-	 * 
-	 */
+    // Modes
+    public static final int IMAGE_PIXELS = 0, STRETCHED = 1, CUSTOM = 2;
+    /**
+     *
+     */
 	private static final long serialVersionUID = 1L;
 	private final JTextField textPath = new JTextField("");
 	private final JButton btnBrowse = new JButton("Browse");
-	private JPanel panelImageRadio = new JPanel();
-
-	private String path = "";
 	private final JPanel panelBrowse = new JPanel();
 	private final JPanel panelOK = new JPanel();
 	private final JButton btnOK = new JButton("OK");
 	private final JLabel lblImage = new JLabel();
-
-	private boolean imageChanged = false;
-	private ImageIcon icon = null;
-	private double imgScale = 1;
 	private final JButton btnCancel = new JButton("Cancel");
 	private final JPanel panelRadio = new JPanel();
 	private final JRadioButton rdbtnImagePixel = new JRadioButton("Use Image Size");
 	private final JRadioButton rdbtnStretched = new JRadioButton("Strech Image");
 	private final JRadioButton rdbtnCustom = new JRadioButton("Custom Size");
 	private final JButton removeImageBtn = new JButton("Remove Background Image");
-	private boolean imageBtnClearedPressed = false;
-
-	// Modes
-	public static final int IMAGE_PIXELS = 0, STRETCHED = 1, CUSTOM = 2;
-	private int mode = 0;
-
 	private final JPanel panel = new JPanel();
 	private final JTextField imageWidth = new JTextField();
 	private final JTextField imageHeight = new JTextField();
-
 	JFileChooser fileChooser;
-
-	public BackgroundPopUp(Model model, Control controller, MyCanvas canvas, CpsUpperNode uNode) {
-		super((java.awt.Frame) null, true);
+    private JPanel panelImageRadio = new JPanel();
+    private String path = "";
+    private boolean imageChanged = false;
+    private ImageIcon icon = null;
+    private double imgScale = 1;
+    private boolean imageBtnClearedPressed = false;
+    private int mode = 0;
+
+    public BackgroundPopUp(Model model, Control controller, MyCanvas canvas, CpsUpperNode uNode, JFrame parentFrame) {
+        super((java.awt.Frame) null, true);
 		getContentPane().setBackground(Color.WHITE);
 		this.setTitle("Set View Background");
 		// Show background Image
@@ -92,7 +67,7 @@ public class BackgroundPopUp extends JDialog {
 		this.setIconImage(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
 				.getScaledInstance(30, 30, Image.SCALE_SMOOTH));
 		setBounds(100, 100, 600, 340);
-		setLocationRelativeTo(this.getParent());
+        setLocationRelativeTo(parentFrame);
 
 		panelBrowse.setBorder(null);
 		panelImageRadio.setBorder(null);

+ 19 - 33
src/ui/view/CanvasResizePopUp.java

@@ -1,50 +1,36 @@
 package ui.view;
 
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Image;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTabbedPane;
-import javax.swing.JTextField;
-
 import ui.controller.Control;
 import ui.model.Model;
 
-public class CanvasResizePopUp extends JDialog {
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 
-	private JPanel mainPanel = new JPanel();
-	private JTextField tFieldWidht = new JTextField();
-	private JTextField tFieldHeight = new JTextField();
-	private JLabel lblWidth = new JLabel("Width:");
-	private JLabel lblHeight = new JLabel("Height:");
+public class CanvasResizePopUp extends JDialog {
 
-	private JPanel buttonPanel = new JPanel();
-	private final JButton btnOk = new JButton("OK");
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1L;
+    private final JButton btnOk = new JButton("OK");
 	private final JButton btnCancel = new JButton("Cancel");
-
 	JTabbedPane tabbedPane;
 	JTabbedPane tabbedPane2;
 	Model model;
 	Control controller;
 	MyCanvas canvas;
-
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 1L;
+    private JPanel mainPanel = new JPanel();
+    private JTextField tFieldWidht = new JTextField();
+    private JTextField tFieldHeight = new JTextField();
+    private JLabel lblWidth = new JLabel("Width:");
+    private JLabel lblHeight = new JLabel("Height:");
+    private JPanel buttonPanel = new JPanel();
 
 	public CanvasResizePopUp(Model model, Control controller, MyCanvas canvas, JTabbedPane tabbedPane,
-			JTabbedPane tabbedPane2) {
-		super((java.awt.Frame) null, true);
+                             JTabbedPane tabbedPane2, JFrame parentFrame) {
+        super((java.awt.Frame) null, true);
 		this.tabbedPane = tabbedPane;
 		this.tabbedPane2 = tabbedPane2;
 		this.model = model;
@@ -56,7 +42,7 @@ public class CanvasResizePopUp extends JDialog {
 				.getScaledInstance(30, 30, Image.SCALE_SMOOTH));
 		this.setTitle("Set the Size of the View");
 		setBounds(200, 100, 200, 100);
-		setLocationRelativeTo(this.getParent());
+        setLocationRelativeTo(parentFrame);
 
 		// MainPanel
 		tFieldWidht.setText("" + model.getCanvasX());

+ 4 - 4
src/ui/view/DisplayedInformationPopUp.java

@@ -30,13 +30,13 @@ public class DisplayedInformationPopUp extends JDialog {
 	 * @param canvas
 	 *            the Canvas
 	 */
-	public DisplayedInformationPopUp(MyCanvas canvas, JPanel update, Control cont) {
-		super((java.awt.Frame) null, true);
+    public DisplayedInformationPopUp(MyCanvas canvas, JPanel update, Control cont, JFrame parentFrame) {
+        super((java.awt.Frame) null, true);
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
 		this.setTitle("Edit Displayed Informations");
 		setBounds(100, 100, 400, 276);
-		setLocationRelativeTo(this.getParent());
-		getContentPane().setLayout(new BorderLayout());
+        setLocationRelativeTo(parentFrame);
+        getContentPane().setLayout(new BorderLayout());
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
 		contentPanel.setLayout(null);

+ 4 - 4
src/ui/view/EditEdgesPopUp.java

@@ -49,13 +49,13 @@ public class EditEdgesPopUp extends JDialog {
 	/**
 	 * Constructor.
 	 */
-	public EditEdgesPopUp() {
-		super((java.awt.Frame) null, true);
+    public EditEdgesPopUp(JFrame parentFrame) {
+        super((java.awt.Frame) null, true);
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
 		this.setTitle(Languages.getLanguage()[46]);
 		setBounds(100, 100, 600, 220);
-		setLocationRelativeTo(this.getParent());
-		getContentPane().setLayout(new BorderLayout());
+        setLocationRelativeTo(parentFrame);
+        getContentPane().setLayout(new BorderLayout());
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
 		contentPanel.setLayout(null);

+ 27 - 29
src/ui/view/GUI.java

@@ -229,7 +229,7 @@ public class GUI implements CategoryListener {
         control.initListener(this);
         controller.setCanvas(canvas);
         model.setConsole(console);
-        algorithmMenu = new AlgorithmMenu(model, control);
+        algorithmMenu = new AlgorithmMenu(model, control, this);
         initialize();
         updateCategories(model.getCategories());
         updCon = new UpdateController(model, controller);
@@ -463,7 +463,7 @@ public class GUI implements CategoryListener {
 
             @Override
             public void actionPerformed(ActionEvent e) {
-                SearchPopUp dialog = new SearchPopUp(controller, canvas);
+                SearchPopUp dialog = new SearchPopUp(controller, canvas, frmCyberPhysical);
                 dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                 dialog.setVisible(true);
             }
@@ -526,7 +526,7 @@ public class GUI implements CategoryListener {
                     }
                 } catch (HeadlessException | JsonParseException | UnsupportedFlavorException | IOException e1) {
                     JLabel message = new JLabel("The Clipboard information cannot be pasted into Application.");
-                    JOptionPane.showMessageDialog(null, message, "", JOptionPane.ERROR_MESSAGE);
+                    JOptionPane.showMessageDialog(frmCyberPhysical, message, "", JOptionPane.ERROR_MESSAGE);
                 }
 
             }
@@ -596,7 +596,7 @@ public class GUI implements CategoryListener {
 
         mntmFindReplace.addActionListener(actionEvent -> {
             try {
-                SearchPopUp dialog = new SearchPopUp(controller, canvas);
+                SearchPopUp dialog = new SearchPopUp(controller, canvas, frmCyberPhysical);
                 dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                 dialog.setVisible(true);
                 controller.getObjectsInDepth();
@@ -608,7 +608,7 @@ public class GUI implements CategoryListener {
         mnNewMenuEdit.add(mntmFindReplace);
         mntmEditShowedInformation.addActionListener(actionEvent -> {
             try {
-                DisplayedInformationPopUp dialog = new DisplayedInformationPopUp(canvas, contentPane, controller);
+                DisplayedInformationPopUp dialog = new DisplayedInformationPopUp(canvas, contentPane, controller, frmCyberPhysical);
                 dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                 dialog.setVisible(true);
             } catch (Exception ex) {
@@ -619,7 +619,7 @@ public class GUI implements CategoryListener {
         mnNewMenuEdit.add(mntmEditShowedInformation);
         mnNewMenuEdit.add(mntmEditEdges);
         mntmEditEdges.addActionListener(actionEvent -> {
-            EditEdgesPopUp edgePopUp = new EditEdgesPopUp();
+            EditEdgesPopUp edgePopUp = new EditEdgesPopUp(frmCyberPhysical);
             edgePopUp.setCanvas(canvas);
             edgePopUp.setController(controller);
             edgePopUp.setVisible(true);
@@ -654,7 +654,7 @@ public class GUI implements CategoryListener {
 
         mnNewMenuView.add(mntmCanvasSize);
         mntmCanvasSize.addActionListener(actionEvent -> {
-            CanvasResizePopUp popUp = new CanvasResizePopUp(model, controller, canvas, tabbedPaneOriginal, tabbedPaneSplit);
+            CanvasResizePopUp popUp = new CanvasResizePopUp(model, controller, canvas, tabbedPaneOriginal, tabbedPaneSplit, frmCyberPhysical);
             popUp.setVisible(true);
         });
 
@@ -724,13 +724,13 @@ public class GUI implements CategoryListener {
             JScrollPane scrollPane = getScrollPaneFromTabbedPane();
 
             if (scrollPane.getViewport().getComponent(0) instanceof MyCanvas) {
-                BackgroundPopUp backgroundDialog = new BackgroundPopUp(model, controller, canvas, null);
+                BackgroundPopUp backgroundDialog = new BackgroundPopUp(model, controller, canvas, null, frmCyberPhysical);
                 backgroundDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                 backgroundDialog.setVisible(true);
             } else if (scrollPane.getViewport().getComponent(0) instanceof UpperNodeCanvas) {
                 UpperNodeCanvas uNodeCanvas = (UpperNodeCanvas) (scrollPane.getViewport().getComponent(0));
                 BackgroundPopUp backgroundDialog = new BackgroundPopUp(model, controller, null,
-                        uNodeCanvas.upperNode);
+                        uNodeCanvas.upperNode, frmCyberPhysical);
                 backgroundDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                 backgroundDialog.setVisible(true);
                 uNodeCanvas.repaint();
@@ -866,7 +866,7 @@ public class GUI implements CategoryListener {
                 AbstractCpsObject tempCpsObject = updCon.getActualCps();
                 if (tempCpsObject != null && tempCpsObject.getClass() == HolonObject.class
                         && tempCpsObject.getId() != 0) {
-                    addElementPopUp = new AddElementPopUp();
+                    addElementPopUp = new AddElementPopUp(frmCyberPhysical);
                     addElementPopUp.setActualCps(updCon.getActualCps());
                     addElementPopUp.setVisible(true);
                     HolonElement ele = addElementPopUp.getElement();
@@ -1412,7 +1412,7 @@ public class GUI implements CategoryListener {
         });
         editItem.addActionListener(actionEvent -> {
             // Remove the selected Object object
-            addObjectPopUP = new AddObjectPopUp(true, tempCps, catOfObjToBeEdited);
+            addObjectPopUP = new AddObjectPopUp(true, tempCps, catOfObjToBeEdited, frmCyberPhysical);
             addObjectPopUP.setCategory(catOfObjToBeEdited);
             addObjectPopUP.setController(controller);
             addObjectPopUP.setVisible(true);
@@ -1438,19 +1438,19 @@ public class GUI implements CategoryListener {
                 switch (selectedOption) {
 
                     case "Category":
-                        String catName = JOptionPane.showInputDialog(Languages.getLanguage()[56]);
+                        String catName = JOptionPane.showInputDialog(frmCyberPhysical, Languages.getLanguage()[56]);
                         if (catName.length() != 0) {
                             controller.addCategory(catName);
                         }
                         break;
                     case "Object":
                         if (selectedNode == null) {
-                            JOptionPane.showMessageDialog(new JFrame(),
+                            JOptionPane.showMessageDialog(frmCyberPhysical,
                                     Languages.getLanguage()[57] + selectedOption + ".");
                         }
                         if (selectedNode != null && selectedNode.getLevel() == 1) {
                             AbstractCpsObject tmp = new HolonObject("");
-                            addObjectPopUP = new AddObjectPopUp(false, tmp, null);
+                            addObjectPopUP = new AddObjectPopUp(false, tmp, null, frmCyberPhysical);
                             addObjectPopUP.setVisible(true);
                             addObjectPopUP.setController(controller);
                             addObjectPopUP.setCategory(selectedNode.toString());
@@ -1472,7 +1472,7 @@ public class GUI implements CategoryListener {
         mntmAboutUs.addMouseListener(new MouseAdapter() {
             @Override
             public void mousePressed(MouseEvent e) {
-                aboutUsPopUp = new AboutUsPopUp();
+                aboutUsPopUp = new AboutUsPopUp(frmCyberPhysical);
                 aboutUsPopUp.setVisible(true);
             }
         });
@@ -1566,7 +1566,7 @@ public class GUI implements CategoryListener {
                 try {
                     switch (depthOfNode) {
                         case 1:
-                            int dialogResult = JOptionPane.showConfirmDialog(null, eraseCategory + nodeName + "?",
+                            int dialogResult = JOptionPane.showConfirmDialog(frmCyberPhysical, eraseCategory + nodeName + "?",
                                     warningText, JOptionPane.YES_NO_OPTION);
                             if (dialogResult == JOptionPane.YES_OPTION) {
                                 controller.deleteCategory(nodeName);
@@ -1578,13 +1578,13 @@ public class GUI implements CategoryListener {
                             break;
 
                         default:
-                            JOptionPane.showMessageDialog(new JFrame(), selectObjBeforeErase);
+                            JOptionPane.showMessageDialog(frmCyberPhysical, selectObjBeforeErase);
                     }
                 } catch (Exception e2) {
                 }
 
             } else {
-                JOptionPane.showMessageDialog(new JFrame(), selectObjBeforeErase);
+                JOptionPane.showMessageDialog(frmCyberPhysical, selectObjBeforeErase);
             }
             tree.repaint();
         });
@@ -1595,7 +1595,7 @@ public class GUI implements CategoryListener {
         mntmNew.addActionListener(actionEvent -> {
             if (model.getObjectsOnCanvas().size() != 0) {
                 int newWarning = JOptionPane.YES_NO_OPTION;
-                int dialogForNewWarning = JOptionPane.showConfirmDialog(null, saveBeforeNew, warningText,
+                int dialogForNewWarning = JOptionPane.showConfirmDialog(frmCyberPhysical, saveBeforeNew, warningText,
                         newWarning);
                 if (dialogForNewWarning == JOptionPane.YES_OPTION) {
                     mntmSave.doClick();
@@ -1623,11 +1623,10 @@ public class GUI implements CategoryListener {
 
             private void menuFileExitActionPerformed() {
                 JFileChooser fileChooser = new JFileChooser();
-                JFrame test = new JFrame();
                 FileNameExtensionFilter holonFilter = new FileNameExtensionFilter("Holon Save File(*.holon)", "holon");
                 fileChooser.setFileFilter(holonFilter);
 
-                if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
+                if (fileChooser.showOpenDialog(frmCyberPhysical) == JFileChooser.APPROVE_OPTION) {
                     File file = fileChooser.getSelectedFile();
 
                     try {
@@ -1641,7 +1640,7 @@ public class GUI implements CategoryListener {
                     } catch (IOException | ArchiveException e) {
                         e.printStackTrace();
                         JLabel message = new JLabel("The savefile is corrupt and cannot be opened.");
-                        JOptionPane.showMessageDialog(null, message, "", JOptionPane.ERROR_MESSAGE);
+                        JOptionPane.showMessageDialog(frmCyberPhysical, message, "", JOptionPane.ERROR_MESSAGE);
                     }
                 }
             }
@@ -1655,11 +1654,10 @@ public class GUI implements CategoryListener {
 
             private void menuSaveActionPerformed() {
                 JFileChooser fileChooser = new JFileChooser();
-                JFrame test = new JFrame();
                 FileNameExtensionFilter holonFilter = new FileNameExtensionFilter("Holon Save File(*.holon)", "holon");
                 fileChooser.setFileFilter(holonFilter);
 
-                if (fileChooser.showSaveDialog(test) == JFileChooser.APPROVE_OPTION) {
+                if (fileChooser.showSaveDialog(frmCyberPhysical) == JFileChooser.APPROVE_OPTION) {
                     String file = fileChooser.getSelectedFile().getPath();
                     if (fileChooser.getFileFilter().equals(holonFilter)) {
                         if (!file.contains("."))
@@ -1672,7 +1670,7 @@ public class GUI implements CategoryListener {
                         JLabel message = new JLabel(
                                 "Are you sure to use the extension \"" + suffix + "\" instead of \".holon\"?");
 
-                        int response = JOptionPane.showOptionDialog(null, message, "", JOptionPane.DEFAULT_OPTION,
+                        int response = JOptionPane.showOptionDialog(frmCyberPhysical, message, "", JOptionPane.DEFAULT_OPTION,
                                 JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
 
                         if (response == 0)
@@ -1833,7 +1831,7 @@ public class GUI implements CategoryListener {
 
         if (nrOfOldSaves > 0) {
             int dialogButton = JOptionPane.YES_NO_OPTION;
-            int dialogResult = JOptionPane.showConfirmDialog(null, "Old autosave file was found, should it be loaded?",
+            int dialogResult = JOptionPane.showConfirmDialog(frmCyberPhysical, "Old autosave file was found, should it be loaded?",
                     warningText, dialogButton);
             if (dialogResult == JOptionPane.YES_OPTION) {
                 if (dest.exists()) {
@@ -1918,13 +1916,13 @@ public class GUI implements CategoryListener {
      */
     private void addObjectAction(String objType, DefaultMutableTreeNode selectedNode) {
         if (selectedNode == null) {
-            JOptionPane.showMessageDialog(new JFrame(),
+            JOptionPane.showMessageDialog(frmCyberPhysical,
                     "Please select a Category first before adding " + objType + ".");
         }
         // if selected node is a directory for Categories
         else {
             if (selectedNode.getLevel() == 1) {
-                String objname = JOptionPane.showInputDialog("Please enter a Name for the " + objType);
+                String objname = JOptionPane.showInputDialog(frmCyberPhysical, "Please enter a Name for the " + objType);
                 Category cat = controller.searchCategory(selectedNode.getUserObject().toString());
 
                 if (objname.length() != 0) {
@@ -1940,7 +1938,7 @@ public class GUI implements CategoryListener {
 
                 }
             } else {
-                JOptionPane.showMessageDialog(new JFrame(),
+                JOptionPane.showMessageDialog(frmCyberPhysical,
                         "Objects can not be added to Objects. Please select a Category.");
             }
         }

+ 8 - 12
src/ui/view/SearchPopUp.java

@@ -1,18 +1,14 @@
 package ui.view;
 
-import java.awt.BorderLayout;
+import classes.AbstractCpsObject;
+import ui.controller.Control;
 
 import javax.swing.*;
 import javax.swing.border.EmptyBorder;
-
-import classes.AbstractCpsObject;
-
-import java.awt.Font;
-
-import ui.controller.Control;
+import java.awt.*;
+import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.ArrayList;
-import java.awt.event.ActionEvent;
 
 /**
  * This Class represents a popup to seatch for Objects on the Canvas.
@@ -41,14 +37,14 @@ public class SearchPopUp extends JDialog {
 	 * @param can
 	 *            Canvas
 	 */
-	SearchPopUp(Control contr, MyCanvas can) {
-		super((java.awt.Frame) null, true);
+    SearchPopUp(Control contr, MyCanvas can, JFrame parentFrame) {
+        super((java.awt.Frame) null, true);
 		idx = -1;
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
 		this.setTitle(Languages.getLanguage()[35]);
 		setBounds(100, 100, 250, 360);
-		setLocationRelativeTo(this.getParent());
-		getContentPane().setLayout(new BorderLayout());
+        setLocationRelativeTo(parentFrame);
+        getContentPane().setLayout(new BorderLayout());
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
 		contentPanel.setLayout(null);