JDK-4221012 : Inconsistent Look&Feel attributes
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.6,1.2.0,1.3.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris_2.6,windows_98
  • CPU: generic,x86,sparc
  • Submitted: 1999-03-17
  • Updated: 2001-06-29
  • Resolved: 2001-06-29
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 :  
Description

Name: dbT83986			Date: 03/16/99


To change the font of the title bar of a JInternalFrame, 
there is no 'general' way to do this.
With Windows L&F, 
   you should use UIManager.put("InternalFrame.titleFont", font)
With Metal L&F
   you should use UIManager.put("InternalFrame.font", font)
With Motif L&F
   don't find what to do ...

Please , may we have consistent way to modify a L&F!
(Review ID: 53944)
======================================================================

Name: boT120536			Date: 01/04/2001


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

public class bugdemo {

        JFrame jFrame;
        Font originalInternalFrameFont;
        Font originalInternalFrameTitleFont;
        String fontKey = "InternalFrame.font";
        String titleFontKey = "InternalFrame.titleFont";
        UIManager ui = new UIManager();

        public static void main(String[] para) {
                bugdemo demo = new bugdemo();
                demo.display();
        }

        public void display() {

                originalInternalFrameFont = (Font) ui.get( fontKey );
                originalInternalFrameTitleFont = (Font) ui.get( titleFontKey );

                jFrame = new JFrame("JFrame Title");
                JDesktopPane desktop = new JDesktopPane();
                jFrame.setContentPane( desktop );

                JInternalFrame iFrame = new JInternalFrame(
                        "JInternalFrame Growing Title", true, true, true, true
);
                desktop.add( iFrame );

                jFrame.setBounds( 10,10,550,350 );
                iFrame.setBounds( 10,10,500,300 );
                
                iFrame.getContentPane().setLayout(
                        new BoxLayout( iFrame.getContentPane(),
BoxLayout.Y_AXIS));

                JButton buttonCross  = new JButton( "Cross LAF" );
                JButton buttonWin    = new JButton( "Win LAF" );
                JButton buttonMotif  = new JButton( "Motif LAF" );
                JButton buttonResetFontSize = new JButton( "Reset internal frame
title font and font size to default" );
                JButton buttonSetInternalFrameFontSize = new JButton( "Enlarge
internal frame font size" );
                JButton buttonSetInternalFrameTitleFontSize = new JButton(
"Enlarge internal frame title font size" );

                JPanel pane0 = new JPanel();
                pane0.setLayout( new BoxLayout( pane0, BoxLayout.Y_AXIS));
                JTextArea jTextArea = new JTextArea();
                
                jTextArea.append( "Inconsistent features :\n" );
                jTextArea.append( "(1) Cross platform Look And Feel internal
frame title font respond to\n" );
                jTextArea.append( "    "  + fontKey + " instead of " +
titleFontKey + "\n");
                jTextArea.append( "(2) Win LAF internal frame title font respond
(correctly) to\n" );
                jTextArea.append( "    " + titleFontKey + "but the title's
heigth not \n" );
                jTextArea.append( "    responding to font size change.\n" );
                jTextArea.append( "(3) Motif LAF title font do not respond to
either key\n" );
                jTextArea.append( "Test platform : Java 2, 1.3 - Win98" );
                pane0.add( jTextArea );

                JPanel pane1 = new JPanel();
                pane1.setLayout( new BoxLayout( pane1, BoxLayout.X_AXIS));
                pane1.add( buttonCross );
                pane1.add( buttonWin );
                pane1.add( buttonMotif );

                JPanel pane2 = new JPanel();
                pane2.setLayout(new GridLayout(0,1));
                pane2.add( buttonResetFontSize );
                pane2.add( buttonSetInternalFrameFontSize );
                pane2.add( buttonSetInternalFrameTitleFontSize );


                iFrame.getContentPane().add( pane0 );
                iFrame.getContentPane().add( pane1 );
                iFrame.getContentPane().add( pane2 );

                buttonCross.addActionListener( new ActionListener() {
                        public void actionPerformed( ActionEvent e ){
                                setLAF(
"javax.swing.plaf.metal.MetalLookAndFeel" );
                        }
                });

                buttonWin.addActionListener( new ActionListener() {
                        public void actionPerformed( ActionEvent e ){
                                setLAF(
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
                        }
                });

                buttonMotif.addActionListener( new ActionListener() {
                        public void actionPerformed( ActionEvent e ){
                                setLAF(
"com.sun.java.swing.plaf.motif.MotifLookAndFeel" );
                        }
                });

                buttonResetFontSize.addActionListener( new ActionListener() {
                        public void actionPerformed( ActionEvent e ){
                                setSize( "" );
                        }
                });

                buttonSetInternalFrameFontSize.addActionListener( new
ActionListener() {
                        public void actionPerformed( ActionEvent e ){
                                setSize( fontKey );
                        }
                });

                buttonSetInternalFrameTitleFontSize.addActionListener( new
ActionListener() {
                        public void actionPerformed( ActionEvent e ){
                                setSize( titleFontKey );
                        }
                });

                iFrame.setVisible( true );
                jFrame.setVisible( true );

        }

        public void setLAF( String LAF ) {
                try {
                        UIManager.setLookAndFeel( LAF );
                } catch (Exception ex) {
                        System.out.println( ex );
                }
                SwingUtilities.updateComponentTreeUI(jFrame);
        }
        
        public void setSize( String key ) {
                // restore original font
                ui.put( fontKey, originalInternalFrameFont );
                ui.put( titleFontKey, originalInternalFrameTitleFont );

                if (!key.equals("")) {
                        Font currentFont = (Font) ui.get( key );
                        ui.put( key, new Font(
                                currentFont.getName(),
                                currentFont.getStyle(),
                                currentFont.getSize() + 15 ));
                }

                SwingUtilities.updateComponentTreeUI(jFrame);
        }
}



  Bug description :
 While enlarging JInternalFrame's title font size, I notice that the title
 apperance and the key (as used by UIManager.put(..)) it respond to
 is inconsistent between different look and feel.
 
 I'm using javax.swing.UIManager's put() method to set
 JInternalFrame's title font.
 
 JInternalFrame's title, while in cross platform look and feel, respond
 to the key : "InternalFrame.font" instead of "InternalFrame.titleFont".
 
 However, in windows look and feel, JInternalFrame's title respond
 correctly to "InternalFrame.titleFont" - however the title's height area is
 not correctly aligned, causing part of the enlarged title chopped off.
 
 JInternalFrame's title does not respond to either key while in
 Motif's look and feel.
 
 I need to enlarge the title font size for JInternalFrame (as well as for
 other components) as I operate in 1024x768 (or higher) resolution.
(Review ID: 109543)
======================================================================

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

EVALUATION Looks like MetalLookAndFeel defines and uses the wrong property. The InternalFrame.font should be InternalFrame.titleFont as defined in the BasicLookAndFeel class. MotifLookAndFeel hard codes the font to use. Oops. I need to check out how Motif deals with internal frames in general. WindowsInternalFrameTitlePane isn't centering the title of the internal frame correctly. joutwate@eng 2001-01-04
04-01-2001