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) { } } }
public void activateFrame(JInternalFrame f) { JInternalFrame currentFrame = currentFrameRef != null ? currentFrameRef.get() : null; try { super.activateFrame(f); if (currentFrame != null && f != currentFrame) { // If the current frame is maximized, transfer that // attribute to the frame being activated. if (currentFrame.isMaximum() && (f.getClientProperty("JInternalFrame.frameType") != "optionDialog")) { // Special case. If key binding was used to select next // frame instead of minimizing the icon via the minimize // icon. if (!currentFrame.isIcon()) { currentFrame.setMaximum(false); if (f.isMaximizable()) { if (!f.isMaximum()) { f.setMaximum(true); } else if (f.isMaximum() && f.isIcon()) { f.setIcon(false); } else { f.setMaximum(false); } } } } if (currentFrame.isSelected()) { currentFrame.setSelected(false); } } if (!f.isSelected()) { f.setSelected(true); } } catch (PropertyVetoException e) { } if (f != currentFrame) { currentFrameRef = new WeakReference(f); } }
@RunsInEDT private static boolean isIcon(final JInternalFrame internalFrame) { return execute(() -> internalFrame.isIcon() && !internalFrame.isMaximum()); }