JDK-4346483 : Maximized JInternalFrame does not maintain state after iconified.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2000-06-19
  • Updated: 2003-03-03
  • Resolved: 2003-03-03
Related Reports
Duplicate :  
Relates :  
Description

Name: stC104175			Date: 06/19/2000


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)


Maximize a JInternalFrame within a standard JDesktopPane with
DefaultDesktopManager.
Iconify the frame.
Re-display the frame by double clicking on the icon.
Presumably, the frame should appear with its last maximized size.
It does not, due to a change from 1.2 to 1.3 in DefaultDesktopManager where,
when iconified, the frame's setMaximum (false) is called.
(Review ID: 106272) 
======================================================================

Name: rmT116609			Date: 10/25/2000


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

/*
Problem: JInternalFrame setIcon(true) does not deiconize to maximizeFrame

Setup:   java.version 1.3.0, NT 4.0 SP6

java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

Try the following:

1) Maximize JInternalFrame using setMaximum(true)
    Result: isIcon() is false /? isMaximum() is true

2) Iconize JInternalFrame using setIcon(true)
??? Result: isIcon() is true /? isMaximum() is false Why?

3) Deiconize JInternalFrame using setIcon(false)
??? Result: isIcon() is false /? isMaximum() is false Why?

//Author:       John Petrula
//Description:  ###@###.###

The code below demos problem.

*/

package com.petrula.bug;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class MyFrame extends JFrame {

  public MyFrame() {
  }

  public static void main(String[] args) {
    try {
    // Windows L&F
    UIManager.setLookAndFeel(
      "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

    // Create Desktop
    JDesktopPane desktopPane = new JDesktopPane();

    // Create JInternalFrame
    JInternalFrame internalFrame =   new JInternalFrame( "My JInternalFrame",true, true, true, true);

    internalFrame.setBounds(200, 200, 200, 200);

    // Create JFrame
    MyFrame myFrame = new MyFrame();
    myFrame.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });

    // Add JInternalFrame into Desktop and set Desktop as ContentPane
    desktopPane.add(internalFrame);
    myFrame.setContentPane(desktopPane);

    // Size and make JFrame visible
    myFrame.setSize(500,500);
    internalFrame.setVisible(true);
    myFrame.setVisible(true);

    // Maximize JInternalFrame

    System.out.println("Maximize using internalFrame.setMaximum(true)");
    internalFrame.setMaximum(true);
    myFrame.validate();
    System.out.println(internalFrame.isIcon()    + " internalFrame.isIcon");
    System.out.println(internalFrame.isMaximum() + "
internalFrame.isMaximum\n");
    Thread.sleep(3000);

    // Iconize JInternalFrame

    // Why is isMaximum() false after iconizing JInternalFrame?
    System.out.println("Iconify using internalFrame.setIcon(true)");
    internalFrame.setIcon(true);
    myFrame.validate();
    System.out.println(internalFrame.isIcon()    + " internalFrame.isIcon");
    System.out.println(internalFrame.isMaximum() + " internalFrame.isMaximum -Why?\n");
    Thread.sleep(3000);

    // Deiconize JInternalFrame

    // Why is isMaximum() false after deiconizing JInternalFrame?
    System.out.println("Deiconify using internalFrame.setIcon(false);");
    internalFrame.setIcon(false);
    myFrame.validate();
    System.out.println(internalFrame.isIcon()    + " internalFrame.isIcon");
    System.out.println(internalFrame.isMaximum() + " internalFrame.isMaximum -Wrong\n");
    }
    catch( Exception e) {
      e.printStackTrace();
    }
  }
}
(Review ID: 108286)
======================================================================

Comments
SUGGESTED FIX Name: apR10133 Date: 12/28/2001 ------- DefaultDesktopManager.java ------- *** /tmp/sccs.tpaG3r Fri Dec 28 20:39:10 2001 --- DefaultDesktopManager.java Fri Dec 28 18:48:24 2001 *************** *** 141,149 **** int layer = lp.getLayer(f); lp.putLayer(desktopIcon, layer); } - if (f.isMaximum()) { - try { f.setMaximum(false); } catch (PropertyVetoException e2) { } - } c.remove(f); c.add(desktopIcon); c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight()); --- 141,146 ---- ------- BasicInternalFrameTitlePane.java ------- *** /tmp/sccs.ERaqYr Fri Dec 28 20:37:09 2001 --- BasicInternalFrameTitlePane.java Fri Dec 28 20:36:36 2001 *************** *** 350,356 **** protected void enableActions() { restoreAction.setEnabled(frame.isMaximum() || frame.isIcon()); ! maximizeAction.setEnabled(frame.isMaximizable() && !frame.isMaximum() ); iconifyAction.setEnabled(frame.isIconifiable() && !frame.isIcon()); closeAction.setEnabled(frame.isClosable()); sizeAction.setEnabled(false); --- 350,357 ---- protected void enableActions() { restoreAction.setEnabled(frame.isMaximum() || frame.isIcon()); ! maximizeAction.setEnabled(frame.isMaximizable() && ! (!frame.isMaximum() || frame.isIcon())); iconifyAction.setEnabled(frame.isIconifiable() && !frame.isIcon()); closeAction.setEnabled(frame.isClosable()); sizeAction.setEnabled(false); *************** *** 544,549 **** --- 545,552 ---- if(frame.isMaximizable()) { if(!frame.isMaximum()) { try { frame.setMaximum(true); } catch (PropertyVetoException e5) { } + } else if (frame.isIcon()) { + try { frame.setIcon(false); } catch (PropertyVetoException e1) { } } else { try { frame.setMaximum(false); *************** *** 586,595 **** public void actionPerformed(ActionEvent e) { if(frame.isMaximizable() && frame.isMaximum()) { ! try { frame.setMaximum(false); } catch (PropertyVetoException e4) { } ! } ! else if ( frame.isIconifiable() && frame.isIcon() ) { ! try { frame.setIcon(false); } catch (PropertyVetoException e4) { } } } } // end RestoreAction --- 589,601 ---- public void actionPerformed(ActionEvent e) { if(frame.isMaximizable() && frame.isMaximum()) { ! if (!frame.isIcon()) { ! try { frame.setMaximum(false); } catch (PropertyVetoException e4) { } ! } else { ! try { frame.setIcon(false); } catch (PropertyVetoException e4) { } ! } ! } else if ( frame.isIconifiable() && frame.isIcon() ) { ! try { frame.setIcon(false); } catch (PropertyVetoException e4) { } } } } // end RestoreAction ------- MotifInternalFrameTitlePane.java ------- *** /tmp/sccs.y_aOYq Fri Dec 28 20:10:49 2001 --- MotifInternalFrameTitlePane.java Fri Dec 28 20:08:20 2001 *************** *** 168,179 **** iFrame.isMaximizable()) { if (!iFrame.isMaximum()) { iFrame.setMaximum(true); ! } else { iFrame.setMaximum(false); } } else if (RESTORE_CMD.equals(e.getActionCommand()) && iFrame.isMaximizable() && iFrame.isMaximum()) { ! iFrame.setMaximum(false); } else if (RESTORE_CMD.equals(e.getActionCommand()) && iFrame.isIconifiable() && iFrame.isIcon()) { iFrame.setIcon(false); --- 168,185 ---- iFrame.isMaximizable()) { if (!iFrame.isMaximum()) { iFrame.setMaximum(true); ! } else if (iFrame.isIcon()) { ! iFrame.setIcon(false); ! } else { iFrame.setMaximum(false); } } else if (RESTORE_CMD.equals(e.getActionCommand()) && iFrame.isMaximizable() && iFrame.isMaximum()) { ! if (!iFrame.isIcon()) { ! iFrame.setMaximum(false); ! } else { ! iFrame.setIcon(false); ! } } else if (RESTORE_CMD.equals(e.getActionCommand()) && iFrame.isIconifiable() && iFrame.isIcon()) { iFrame.setIcon(false); *************** *** 198,208 **** systemMenu.getComponentAtIndex(MAXIMIZE_MENU_ITEM).setEnabled(!value); } else if(JInternalFrame.IS_ICON_PROPERTY.equals(prop)) { value = ((Boolean)evt.getNewValue()).booleanValue(); ! systemMenu.getComponentAtIndex(RESTORE_MENU_ITEM).setEnabled(value); ! if (f.isMaximizable()) ! systemMenu.getComponentAtIndex(MAXIMIZE_MENU_ITEM).setEnabled(true); ! else ! systemMenu.getComponentAtIndex(MAXIMIZE_MENU_ITEM).setEnabled(false); systemMenu.getComponentAtIndex(MINIMIZE_MENU_ITEM).setEnabled(!value); } else if( prop.equals("maximizable") ) { if( (Boolean)evt.getNewValue() == Boolean.TRUE ) --- 204,223 ---- systemMenu.getComponentAtIndex(MAXIMIZE_MENU_ITEM).setEnabled(!value); } else if(JInternalFrame.IS_ICON_PROPERTY.equals(prop)) { value = ((Boolean)evt.getNewValue()).booleanValue(); ! if (!value && f.isMaximum()) { ! systemMenu.getComponentAtIndex(RESTORE_MENU_ITEM).setEnabled(true); ! } else { ! systemMenu.getComponentAtIndex(RESTORE_MENU_ITEM).setEnabled(value); ! } ! if (f.isMaximizable()) { ! if (value || !f.isMaximum()) { ! systemMenu.getComponentAtIndex(MAXIMIZE_MENU_ITEM).setEnabled(true); ! } else { ! systemMenu.getComponentAtIndex(MAXIMIZE_MENU_ITEM).setEnabled(false); ! } ! } else { ! systemMenu.getComponentAtIndex(MAXIMIZE_MENU_ITEM).setEnabled(false); ! } systemMenu.getComponentAtIndex(MINIMIZE_MENU_ITEM).setEnabled(!value); } else if( prop.equals("maximizable") ) { if( (Boolean)evt.getNewValue() == Boolean.TRUE ) ###@###.### ======================================================================
11-06-2004

EVALUATION I noticed this as well. I'm not sure why this was changed in 1.3. This certainly isn't correct for the WindowsLookAndFeel. I don't think this was intended. I need to talk to Human Interfaces about this just to make sure this wasn't intended for Metal though I doubt it. joutwate@eng 2001-01-22 Name: apR10133 Date: 12/28/2001 This changes was introduced with fix for bug #4151444. Due to this fix the DefaultDesktopManager.iconifyFrame() always sets frame's state to not maximum. We can't just remove it due to the bug #4151444. So we have to provide the decision wich could fix both bugs: #4151444 and the current one. It is important to fix the problem not for titlepane's buttons only, but for the system menu too. ###@###.### The two bugs are not different. It seems that there was some confusion in the past regarding desktop management. Just because a frame is set to be an icon does not mean it can't be maximized at the same time. It's just that the iconify state overrides the maximize state. I am consolidating all these bugs into one 4424247. Closing as a duplicate. ###@###.### 2003-03-03
03-03-2003