swing - JTextpane does not respect visibleEditorRect with java 8 -


run below code both java 6 , java 8, , see result. line breaks works within bounds of visibleeditorrect on java 6, on java 8 string overflow bounds. there workaround problem.

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);             };         }              );     } } } 

i resolve problem reverting breaking behavior java 6 functionality. overwriting getbreakweight , getbreakspot methods copying java 6 in extention of labelview enough.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -