Total members 11894 |It is currently Sat Nov 23, 2024 4:03 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





draw text effects in java
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;

public class TextRenderingExample extends JPanel {
  public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    Dimension dim = getSize();
    AffineTransform affineTransform = AffineTransform.getTranslateInstance(
    dim.width / 2,dim.height * 3 / 4);
    g2d.transform(affineTransform);

    String st = "Welcome";
    Font font = new Font("Book Antiqua", Font.PLAIN, 50);
    g2d.setFont(font);
    g2d.setColor(Color.red);
    int counter = 18;
    for (int k = 1; k <= counter; k++) {
      AffineTransform transform = g2d.getTransform();
      float num1 = (float) k / (float) counter;
      g2d.transform(AffineTransform.getRotateInstance(Math.PI
          * (num1 - 1.0f)));
      float num2 = ((k == counter) ? 1.0f : num1 / 3);
      g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
          num2));
      g2d.drawString(st, 0, 0);
    g2d.setTransform(transform);
    }
  }
public static void main(String[] args) {
    JFrame frame = new JFrame("Text Rendering Example");
    frame.getContentPane().add(new TextRenderingExample());
    frame.setSize(450, 350);
    frame.show();
  }
}





Attachments:
File comment: output
textRendering.gif
textRendering.gif [ 19.36 KiB | Viewed 6395 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 : draw text effects in java
 java image effects     -  
 Java- Copy text area into disabled text area     -  
 Draw An Arc in java     -  
 Draw Flag in Java     -  
 draw Calendar in java     -  
 draw Oval in java     -  
 Draw Dashed Oval in java     -  
 Changing the color of a graph draw in java     -  
 Java code to draw shortest path tree     -  
 Using Filters Effects     -  









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