private void setState(JDesktopPane dp, String state) { if (state == CLOSE) { JInternalFrame f = dp.getSelectedFrame(); if (f == null) { return; } f.doDefaultCloseAction(); } else if (state == MAXIMIZE) { // maximize the selected frame JInternalFrame f = dp.getSelectedFrame(); if (f == null) { return; } if (!f.isMaximum()) { if (f.isIcon()) { try { f.setIcon(false); f.setMaximum(true); } catch (PropertyVetoException pve) { } } else { try { f.setMaximum(true); } catch (PropertyVetoException pve) { } } } } else if (state == MINIMIZE) { // minimize the selected frame JInternalFrame f = dp.getSelectedFrame(); if (f == null) { return; } if (!f.isIcon()) { try { f.setIcon(true); } catch (PropertyVetoException pve) { } } } else if (state == RESTORE) { // restore the selected minimized or maximized frame JInternalFrame f = dp.getSelectedFrame(); if (f == null) { return; } try { if (f.isIcon()) { f.setIcon(false); } else if (f.isMaximum()) { f.setMaximum(false); } f.setSelected(true); } catch (PropertyVetoException pve) { } } }
/** * 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()); }
// Aqui no creo que deba ir un TaskFrame por si se quiere activar otro tipo de JinternalFrame public void activateFrame(JInternalFrame frame) { frame.moveToFront(); frame.requestFocus(); try { frame.setSelected(true); if (!(frame instanceof TaskFrame)) { frame.setMaximum(false); } } catch (PropertyVetoException e) { warnUser(StringUtil.stackTrace(e)); } }