JDK-4242045 : JInternalFrame titlepane icons not restored after attribute change
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0,1.2.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_95,windows_nt
  • CPU: x86
  • Submitted: 1999-05-27
  • Updated: 2000-04-19
  • Resolved: 2000-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Related Reports
Duplicate :  
Relates :  
Description

Name: vi73552			Date: 05/27/99


Searched the JDC for the bugs elicited by the example below and could not find them.  Happens under jdk 1.2 using both Windows L&F and Metal L&F... Did not try under latest Swing beta.

Running the example below:

1) Press MakeFrame

2) Note that JIF is closable, resizable, minimizable

3) Click each of the closable, resizable, minimizable JButtons in the JIF (turning these attribs off).  Note that the respective JIF titlebar action icons disappear as expected. (Note: the JIF also grows a pixel with each button press, I'm using setBounds with new values just to force the JIF to repaint after each button press).

4) MINOR BUG: Under Windows L&F, press the titlebar (coffee cup) icon... Minimize, Maximize , Close choices are NOT grayed out as they should be (but they do not function, which is correct).  If you re-enable Iconifiable then iconify & de-iconify the JIF, these choices show up as properly grayed.

5) THE BUGS: Now with the restored JIF, re-enable Closable & Maximizable (using the JButtons, set these to true)... Note these bugs:

  a)  The biggie:  The respective JIF titlebar action icons (the closable X and Maximizable box) DO NOT REAPPEAR as they should.

  b)  Under Windows L&F, press the titlebar (coffee cup) 
icon...  Maximize , Close choices are STILL grayed out (not usable), and they should now be available. Iconify & de-iconify the JIF & these are properly show.

Seems like some property changes are not be fired or implemented within the title bar UIs.

The real problem is the fact that the Minimize, Maximize & Close icons cannot be made to reappear in the titlebar once they are disabled.

Sample code:

// Demonstrates JInternalFrame problems with dynamic attributes & titlepane icons

import javax.swing.*;
import javax.swing.event.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.plaf.basic.BasicInternalFrameUI;

import com.sun.java.swing.plaf.windows.*;  //  Needed for Windows L&F

public class JFrame1 extends JFrame {
   static int frameCount = 1;
   
   public JFrame1() {
      super("Internal Frames Demo");
      
      try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());  }
      catch (Exception exc) {   System.out.println("Error loading L&F: " + exc); }
      
      final JDesktopPane desktop = new JDesktopPane();
      getContentPane().add(desktop,BorderLayout.CENTER);
      JInternalFrame makeFrame = new JInternalFrame("Frame Maker",true,false,true,true);
      
      JButton button = new JButton("Make Frame");
      button.addActionListener(new ActionListener() {  
		public void actionPerformed(java.awt.event.ActionEvent event) {
            final JInternalFrame internal = 
                new JInternalFrame("Frame #" + frameCount,true,true,true,true);
            internal.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            Container contentPane = internal.getContentPane();
            contentPane.setLayout(new BoxLayout(contentPane,BoxLayout.Y_AXIS));
            
            // Add buttons to flip attributes
            final JButton Closable = new JButton("Closable: true");
            Closable.addActionListener(new ActionListener() {  
		        public void actionPerformed(java.awt.event.ActionEvent event) {
		            // Flip closable attribute
		            internal.setClosable(!internal.isClosable());
		            Closable.setText("Closable: "+internal.isClosable());
		            // Resize JIF just to get the Title Pane to repaint
		            Rectangle r = internal.getBounds();
		            r.grow(1, 1);
		            internal.setBounds(r);
		        }
            });
            contentPane.add(Closable);
            
            final JButton Iconifiable = new JButton("Iconifiable: true");
            Iconifiable.addActionListener(new ActionListener() {  
		        public void actionPerformed(java.awt.event.ActionEvent event) {
		            // Flip Iconifiable attribute
		            internal.setIconifiable(!internal.isIconifiable());
		            Iconifiable.setText("Iconifiable: "+internal.isIconifiable());
		            // Resize JIF just to get the Title Pane to repaint
		            Rectangle r = internal.getBounds();
		            r.grow(1, 1);
		            internal.setBounds(r);
		        }
            });
            contentPane.add(Iconifiable);
            
            final JButton Maximizable = new JButton("Maximizable: true");
            Maximizable.addActionListener(new ActionListener() {  
		        public void actionPerformed(java.awt.event.ActionEvent event) {
		            // Flip Maximizable attribute
		            internal.setMaximizable(!internal.isMaximizable());
		            Maximizable.setText("Maximizable: "+internal.isMaximizable());
		            // Resize JIF just to get the Title Pane to repaint
		            Rectangle r = internal.getBounds();
		            r.grow(1, 1);
		            internal.setBounds(r);
		        }
            });
            contentPane.add(Maximizable);
            
            internal.setBounds(frameCount*25,frameCount*25,200,150);
            desktop.add(internal);
            frameCount++;
            if (frameCount > 10) frameCount=0;
		}
      });
      makeFrame.getContentPane().add(button,BorderLayout.CENTER);
      makeFrame.setBounds(200,0,200,75);
      desktop.add(makeFrame);
      setSize(500,500);
      this.addWindowListener( new WindowAdapter() {
        public void windowClosing(WindowEvent event)  {
            setVisible(false);         		
            dispose();	            		
            System.exit(0);      		
        }    	
      });
      show();
   }
    public static void main(String args[]) {
        new JFrame1();   
    }
 }
(Review ID: 83516) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta FIXED IN: merlin-beta INTEGRATED IN: merlin-beta
14-06-2004

WORK AROUND Name: vi73552 Date: 05/27/99 None. ======================================================================
11-06-2004

SUGGESTED FIX ------- MotifInternalFrameTitlePane.java ------- *** /tmp/dGajZI_ Thu Mar 16 15:40:33 2000 --- MotifInternalFrameTitlePane.java Thu Mar 16 15:28:54 2000 *************** *** 195,201 **** else systemMenu.getComponentAtIndex(MAXIMIZE_MENU_ITEM).setEnabled(false); systemMenu.getComponentAtIndex(MINIMIZE_MENU_ITEM).setEnabled(!value); ! } } public void addLayoutComponent(String name, Component c) {} --- 195,215 ---- 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 ) ! add(maximizeButton); ! else ! remove(maximizeButton); ! revalidate(); ! repaint(); ! } else if( prop.equals("iconable") ) { ! if( (Boolean)evt.getNewValue() == Boolean.TRUE ) ! add(minimizeButton); ! else ! remove(minimizeButton); ! revalidate(); ! repaint(); ! } } public void addLayoutComponent(String name, Component c) {} ###@###.### 2000-03-16
16-03-2000

EVALUATION In jdk1.3, this code behaves somewhat differently than described in the report, but there are still bugs there, particularly in Motif. hania.gajewska@Eng 1999-09-20 The cause of this bug is that the title of the internal frame is not repaints when we add/remove buttons in title pane. This bug is particularly fixed in 4134077 (for Metal and Windows LAF) but in MotifInternalFrameTitlePane we should check the "iconable" and "maximizable" properties events to revalidate and repaint the title. ###@###.### 2000-03-16
16-03-2000