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

JTextpane visibleEditorRect has no effect on java 7 and java 8

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • 8, 9
    • client-libs

      FULL PRODUCT VERSION :
      java version "1.8.0_40"
      Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
      Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Sürüm 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      The problem occurs when BasicTextPaneUI getVisibleEditorRect method overriden. At the version java 6 everything goes as expected but at java 7 and the later version jtextpane does not care about the area defined by getVisibleEditorRect method.

      REGRESSION. Last worked in version 6u45

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.6.0_45"
      Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
      Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode, sharing)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the code given in test code both java 6 and java 8


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      expected result is , at the visibleRect area border Jtextpane must break the line to next one
      ACTUAL -
      at java 6 above code runs as expected but at java 8 the line overflow the visibleEditorRect area

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Rectangle;

      import javax.swing.JFrame;
      import javax.swing.JTextPane;
      import javax.swing.plaf.basic.BasicTextPaneUI;

      public class TextPaneBug {

      public static void main(String[] args) {
      JFrame f = new JFrame() ;
      JTextPane text = new BugTextPane() ;
      f.add(text);
      text.setText("mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
      f.setExtendedState(JFrame.MAXIMIZED_BOTH);
      f.setVisible(true);
      }

      static class BugTextPane extends JTextPane
      {
      public BugTextPane() {
      setUI(new BasicTextPaneUI(){
      @Override
      protected Rectangle getVisibleEditorRect() {
      Rectangle r = super.getVisibleEditorRect() ;
      Rectangle newr = new Rectangle(r.width / 2 - 300 , r.height/2 - 300 , 600 ,600) ;
      return newr;
      }
      protected void paintSafely(java.awt.Graphics g) {
      super.paintSafely(g);
      Rectangle r = getVisibleEditorRect() ;
      g.drawRect(r.x,r.y,r.width,r.height);
      };
      }

      );
      }
      }
      }
      ---------- END SOURCE ----------

            ssadetsky Semyon Sadetsky (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: