Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Graphics2D g2d = bi.createGraphics();
- g2d.setColor(Color.RED);
- g2d.fillRect(0,0,100,100);
- BufferedImage bi;
- Graphics2D g2d = bi.createGraphics();
- g2d.setPaint (new Color(r, g, b));
- g2d.fillRect (0, 0, bi.getWidth(), bi.getHeight());
- TexturePaint tp = new TexturePaint(myImage, new Rectangle(0, 0, 16, 16));
- g2d.setPaint(tp);
- public class TexturePanel extends JPanel {
- private TexturePaint paint;
- public TexturePanel(BufferedImage bi) {
- super();
- this.paint = new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));
- }
- @Override
- protected void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- g2.setPaint(paint);
- g2.fill(new Rectangle(0, 0, getWidth(), getHeight()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement