Total members 11890 |It is currently Fri Apr 19, 2024 1:24 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Text Texture in java
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;

public class 
TextTexturedExample extends JPanel {
  public 
void paint(Graphics g) {
    
Graphics2D g2d = (Graphics2Dg;
    
Font font = new Font("Monotype Corsiva"Font.PLAIN40);
    
g2d.setFont(font);
    
String st "Java is an Object Oriented Programming Language.";
    
BufferedImage bufferedImage getTextureImage();
    
Rectangle rect = new Rectangle(00bufferedImage.getWidth(),
            
bufferedImage.getHeight());
    
TexturePaint texturePaint = new TexturePaint(bufferedImagerect);
    
g2d.setPaint(texturePaint);
    
g2d.drawString(st20100);
  }
  private 
BufferedImage getTextureImage() {
    
int s=10;
    
BufferedImage bufferedImage = new BufferedImage(ss,
             
BufferedImage.TYPE_INT_RGB);
    
Graphics2D g2d bufferedImage.createGraphics();
    
g2d.setPaint(Color.blue);
    
g2d.fillRect(0022);
    
g2d.setPaint(Color.green);
    
g2d.fillRect(20s2);
    
g2d.setPaint(Color.yellow);
    
g2d.fillRect(022s);
    
g2d.setPaint(Color.red);
    
g2d.fillRect(22ss);
  return 
bufferedImage;
  }
  public static 
void main(String[] args) {
    
JFrame f = new JFrame("Text Textured Example");
    
f.getContentPane().add(new TextTexturedExample());
    
f.setSize(760200);
    
f.show();
}





Attachments:
File comment: output
textTextured.gif
textTextured.gif [ 10.69 KiB | Viewed 4892 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 ] 

  Related Posts  to : Text Texture in java
 Java- Copy text area into disabled text area     -  
 add texture to cube3D     -  
 Add light to texture     -  
 Add texture to teapot object using     -  
 how to attach a texture to polygon     -  
 Text to speech in java     -  
 draw text effects in java     -  
 java Break Line for text     -  
 change Font of text in java     -  
 uploading text file to java program     -  



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