#navi(contents-page-name): No such page: ST

Terai Atsuhiro 2023-10-12 (木) 10:58:52

http://terai.s55.xrea.com/swing/texturepaint/screenshot.png

URL url = MainPanel.class.getResource("16x16.png");
BufferedImage img = null;
try {
  img = ImageIO.read(url);
}catch(IOException ioe) {
  ioe.printStackTrace();
}
Rectangle2D r2d = new Rectangle2D.Double(0,0,img.getWidth(),img.getHeight());
texture = new TexturePaint(img, r2d);
public void paintComponent(Graphics g) {
  Graphics2D g2 = (Graphics2D)g;
  g2.setPaint(texture);
  g2.fillRect(0, 0, getWidth(), getHeight());
  super.paintComponent(g);
}
  • ST/BackgroundImage