/** * Reacts to property change events 'editorClosing', 'closeFrame', and 'name'. * * @param e the property change event. */ public void propertyChange(PropertyChangeEvent e) { // Handles the removal of editor frames from desktop String name = e.getPropertyName(); if ("editorClosing".equals(name)) { // find NewValue in String array, and remove for (int n = 0; n < sessionNodeKeys.size(); n++) { if (e.getNewValue().equals((sessionNodeKeys.get(n)))) { sessionNodeKeys.remove(n); } } } else if ("closeFrame".equals(e.getPropertyName())) { if (getFramesMap().containsKey(e.getSource())) { Object frameObject = getFramesMap().get(e.getSource()); JInternalFrame frame = (JInternalFrame) frameObject; frame.setVisible(false); frame.dispose(); } } else if ("name".equals(e.getPropertyName())) { if (getFramesMap().containsKey(e.getSource())) { Object frameObject = getFramesMap().get(e.getSource()); JInternalFrame frame = (JInternalFrame) frameObject; String _name = (String) (e.getNewValue()); frame.setTitle(_name); setMainTitle(_name); } } }
/** * Adds a component to the middle layer of the desktop--that is, the layer for session node * editors. Note: The comp is a SessionEditor */ public void addSessionEditor(SessionEditorIndirectRef editorRef) { SessionEditor editor = (SessionEditor) editorRef; JInternalFrame frame = new TetradInternalFrame(null); frame.getContentPane().add(editor); framesMap.put(editor, frame); editor.addPropertyChangeListener(this); // Set the "small" size of the frame so that it has sensible // bounds when the users unmazimizes it. Dimension fullSize = desktopPane.getSize(); int smallSize = Math.min(fullSize.width - MARGIN, fullSize.height - MARGIN); Dimension size = new Dimension(smallSize, smallSize); setGoodBounds(frame, desktopPane, size); desktopPane.add(frame); // Set the frame to be maximized. This step must come after the frame // is added to the desktop. -Raul. 6/21/01 try { frame.setMaximum(true); } catch (Exception e) { throw new RuntimeException("Problem setting frame to max: " + frame); } desktopPane.setLayer(frame, 0); frame.moveToFront(); frame.setTitle(editor.getName()); frame.setVisible(true); setMainTitle(editor.getName()); }