Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6459404

jTextPane/jEditorPane text space higher than before

XMLWordPrintable

    • 2d
    • b45
    • 6
    • b03
    • x86
    • windows_xp
    • Verified

        FULL PRODUCT VERSION :
        <build 1.6.0-rc-b94, mixed mode, sharing>

        ADDITIONAL OS VERSION INFORMATION :
        Windows XP - Professional - Version 2002 Service Pack 2

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Laptop IBM T42P

        A DESCRIPTION OF THE PROBLEM :
        I use a jEditorPane to display some RTF text, no problem at all since the JDK 1.3 until JDK 1.5. But when I try to display some saved documents with Mustang as JDK, it seems that the height of each line has been increased. The consequence of this change is that a text cannot appear completely anymore (I don’t use any jScrollPane, in fact the size of the editorPane is fixed in advance definitively). After analyzing the values returned by some methods provided within the class BoxView, I’ve noticed that the height of the spans has been increased as compared to the values returned before.

        for example:

        Font used: Arial size 11
        Jdk 1.5 : Span = 14
        Mustang: Span =15

        Font used: Arial size 16

        Jdk 1.5 : Span = 19
        Mustang: Span =21


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Put a jEdtorPane into a frame and launch this simple application under the jdk1.5 and after the latest release of mustang. Compare directly the result on the screen. Try to enter a text composed of several lines (Arial font)

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        By using the jdk 1.5 or previous the text takes less height space than using mustang

        ---------- BEGIN SOURCE ----------

        main class: test.java
        *************************************

        package editor;

        import java.awt.Toolkit;
        import javax.swing.SwingUtilities;
        import javax.swing.UIManager;
        import java.awt.Dimension;

        /**
         * <p>Title: </p>
         *
         * <p>Description: </p>
         *
         * <p>Copyright: Copyright (c) 2006</p>
         *
         * <p>Company: </p>
         *
         * @author not attributable
         * @version 1.0
         */
        public class test {
            boolean packFrame = false;

            /**
             * Construct and show the application.
             */
            public test() {
                Frame1 frame = new Frame1();
                // Validate frames that have preset sizes
                // Pack frames that have useful preferred size info, e.g. from
        their layout
                if (packFrame) {
                    frame.pack();
                } else {
                    frame.validate();
                }

                // Center the window
                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                Dimension frameSize = frame.getSize();
                if (frameSize.height > screenSize.height) {
                    frameSize.height = screenSize.height;
                }
                if (frameSize.width > screenSize.width) {
                    frameSize.width = screenSize.width;
                }
                frame.setLocation((screenSize.width - frameSize.width) / 2,
                                  (screenSize.height - frameSize.height) / 2);
                frame.setVisible(true);
            }

            /**
             * Application entry point.
             *
             * @param args String[]
             */
            public static void main(String[] args) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        try {
                            UIManager.setLookAndFeel(UIManager.

        getSystemLookAndFeelClassName());
                        } catch (Exception exception) {
                            exception.printStackTrace();
                        }

                        new test();
                    }
                });
            }
        }


        *************************************

        Second classe Frame1:

        *************************************

        package editor;

        import java.awt.BorderLayout;
        import java.awt.Dimension;

        import javax.swing.*;
        import javax.swing.text.*;

        /**
         * <p>Title: </p>
         *
         * <p>Description: </p>
         *
         * <p>Copyright: Copyright (c) 2006</p>
         *
         * <p>Company: </p>
         *
         * @author not attributable
         * @version 1.0
         */
        public class Frame1 extends JFrame {
            JPanel contentPane;
            BorderLayout borderLayout1 = new BorderLayout();
            JTextPane editor;
            String text="The Caterpillar and Alice looked at each other for some
        time in silence: at last the Caterpillar took the hookah out of its mouth,
        and addressed her in a languid, sleepy voice.";

            public Frame1() {
                try {
                    setDefaultCloseOperation(EXIT_ON_CLOSE);
                    jbInit();
                } catch (Exception exception) {
                    exception.printStackTrace();
                }
            }

            /**
             * Component initialization.
             *
             * @throws java.lang.Exception
             */
            private void jbInit() throws Exception {
                contentPane = (JPanel) getContentPane();
                contentPane.setLayout(null);
                setSize(new Dimension(400, 300));
                setTitle("Frame Title");
                editor = new JTextPane();

                editor.setBounds(10,10,150,150);
                contentPane.add(editor);

                MutableAttributeSet attr = new SimpleAttributeSet();
                StyleConstants.setFontFamily(attr, "Arial");
                StyleConstants.setFontSize(attr, 11);
                editor.getDocument().insertString(0,text,attr);
            }
        }
        ---------- END SOURCE ----------

        REPRODUCIBILITY :
        This bug can be reproduced always.

        Release Regression From : 5.0u7
        The above release value was the last known release where this
        bug was not reproducible. Since then there has been a regression.

              prr Philip Race
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: