Switch to full style
General Java code examples
Post a reply

Stroke with Effect in java

Tue Nov 11, 2008 6:12 pm

Stroke with Effect in java
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;

public class EffectsOfStroke extends JPanel{
  public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    double p = 12, q = 45, width = 65, height = 65;
    Rectangle2D rectangle = new Rectangle2D.Double(p, q, width, height);
    GradientPaint gradientPaint= new GradientPaint(65, 65, Color.red,
      90, 90,Color.cyan, true);
    g2d.setPaint(gradientPaint);
    g2d.fill(rectangle);
    rectangle.setFrame(+ 90, q, width, height);
    g2d.setPaint(gradientPaint);
    g2d.setStroke(new BasicStroke(10));
    g2d.draw(rectangle);
    rectangle.setFrame(+ 180, q, width, height);
    g2d.setPaint(Color.black);
    g2d.draw(rectangle);
  }

  public static void main(String[] args) {
    JFrame frame = new JFrame("Show Effect");
    frame.getContentPane().add(new EffectsOfStroke());
    frame.setSize(350, 200);
    frame.show();
  }
}
 



Attachments
effect.gif
the output
effect.gif (7.61 KiB) Viewed 5685 times

Post a reply
  Related Posts  to : Stroke with Effect in java
 photoshop Glass Effect     -  
 Lightning Text Effect     -  
 Text Effect Using Photoshop     -  
 photoshop Glass Effect     -  
 make Water mark Effect in php     -  
 Text Effect Using Add Layer Style     -  
 2d game in java-Monster-Java 2D Game Graphics and Animation     -  
 Java course     -  
 Using FTP in java     -  
 What is Java API?!!!     -  

Topic Tags

Java Graphics