java - How use a 9-patch image as background on a JPanel? -


i'm searching way use 9-patch file background javax.swing.jpanel. background image automatically resizes when dimensions of jpanel change.

is possible? or have create pieces of image , manually resize of them when listener triggers (like in piece of code follows)?

public class jpanelwithninepatchbackground extends jpanel {  {      /* define parts of background bufferedimage */      addcomponentlistener(new componentadapter() {          public void componentresized(componentevent e) {               // resize images . . .               jpanelwithbackground.this.repaint();          }      });      /* . . . */  } 

yes, use either of drawimage() implementations let specify corners of destination rectangle. method complete faster if source , destination rectangles match in size. rctile example.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -