Saturday 15 February 2014

java - Painting a rounded border onto a JScrollPane -



java - Painting a rounded border onto a JScrollPane -

i trying paint rounded rectangle around jscrollpane. life of me can't figure out how this! no matter try, border not visible. have figured out drawing behind contents , not on them. thing within scroll pane jpanel graphics painted onto it. know how prepare this?

here code have tried paint border on scroll pane:

public void paintcomponent(graphics g) { super.paintcomponent(g); graphics2d g2 = (graphics2d) g; g2.setrenderinghint(renderinghints.key_rendering, renderinghints.value_render_quality); g2.setrenderinghint(renderinghints.key_antialiasing, renderinghints.value_antialias_on); g2.setcolor(color.black); g2.setstroke(new basicstroke(1)); g2.draw(new roundrectangle2d.double(0, 0, getwidth() - 1, getheight() - 1, 10, 10)); }

i have tried using paint instead of paintcomponent no such luck!

you painting outside of components bounds, big no-no, , why having problem. should consider creating custom border or extending component insets have room paint outline

java swing border

No comments:

Post a Comment