Total members 11892 |It is currently Sun Sep 08, 2024 4:37 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





draw Textured Paint in java
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;

public class 
ShowTexturePaint extends JPanel {
 
  public 
void paint(Graphics g) {
    
Graphics2D g2d = (Graphics2Dg;
    
BufferedImage bufferedImage = new BufferedImage(88,
        
BufferedImage.TYPE_INT_RGB);
    
Graphics2D g2 bufferedImage.createGraphics();
    
g2.setColor(Color.red);
    
g2.fillRect(0088);
    
g2.setColor(Color.gray);
    
g2.fillOval(0088);
    
Rectangle2D rect = new Rectangle2D.Double(5588);
    
g2d.setPaint(new TexturePaint(bufferedImagerect));
    
Ellipse2D oval = new  Ellipse2D.Double(8,8,250,250);
    
g2d.fill(oval);
  }
  public static 
void main(String args[]) {
    
JFrame frame = new JFrame("Show Texture Paint");
    
ShowTexturePaint texturePaint = new ShowTexturePaint();
    
frame.getContentPane().add("Center"texturePaint);
    
frame.setSize(350300);
    
frame.setVisible(true);
  }





Attachments:
File comment: Java textured paint
texturePaint.gif
texturePaint.gif [ 7.63 KiB | Viewed 5159 times ]

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada
Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 




Topic Tags

Java Graphics






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com