java - JTextPane is going out of boundary from JDialog -


chattextpane = new jtextpane(); chattextpane.setpreferredsize(new dimension(350,150)); //chattextpane.setmaximumsize(new dimension(350,150));//new scrollingtextpane = new jscrollpane(chattextpane); scrollingtextpane.sethorizontalscrollbarpolicy(jscrollpane.horizontal_scrollbar_always); scrollingtextpane.setverticalscrollbarpolicy(jscrollpane.vertical_scrollbar_always); //scrollingtextpane.setmaximumsize(new dimension(350,150)); 

i'm writing chat program on jdialog. jtextpane going out of boundary jdialog. have added 2 pictures. 1 before closing jdialog window , other after opening jdialog window again.

get rid of chattextpane.setpreferredsize(new dimension(350,150));. it's prevent telling jscrollpane how big should be.

take @ should avoid use of set(preferred|maximum|minimum)size methods in java swing? more reasons why should avoid using setpreferredsize...just in case mistake time didn't make clear ;)


Comments