File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,7 +102,17 @@ protected void paintNotSelected(Graphics g) {
102102 //draw string starts from bottom left corner, shift to top left
103103 updateBoundsAndDrawString (g );
104104 }
105- public void updateBoundsAndDrawString (Graphics g ) {
105+ private void updateBoundsAndDrawString (Graphics g ) {
106+ updateBounds (g );
107+ drawString (g );
108+
109+ }
110+
111+ /**
112+ * Update bounds updates the width and row height of this text paint component
113+ * @param g Graphics Object
114+ */
115+ public void updateBounds (Graphics g ) {
106116 //reset bounds to begin calculation
107117 width = 0 ;
108118 //derive row Height
@@ -120,6 +130,20 @@ public void updateBoundsAndDrawString(Graphics g) {
120130 if ( curStringWidth > width ){
121131 width = curStringWidth ;
122132 }
133+ }
134+ }
135+
136+ /**
137+ * Draws the string, do not update bounds
138+ * @param g
139+ */
140+ private void drawString (Graphics g ){
141+
142+ //get number of rows
143+ String [] rows = this .displayingText .split ("\n " );
144+
145+ for (int i = 0 ; i < rows .length ; i ++) {
146+ String string = rows [i ];
123147
124148 g .drawString (string , getX (), (int ) (getY () + rowHeight * (i + 1 )));
125149 }
You can’t perform that action at this time.
0 commit comments