drawing arc

Wednesday, December 21, 2011


package grafik;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import javax.swing.*;


public class DrawingArcs extends JPanel {
    public DrawingArcs(){setBackground(Color.CYAN);}
    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 =(Graphics2D)g;


        g.setColor(Color.PINK);
        g.fillArc(20,20,80,80,45,180);


        g.setColor(Color.black);
        g.setFont(new Font("Calibri", Font.BOLD,12));
        g.drawString("ini adalah arcs", 10, 50);


        g2.setColor(Color.BLUE);
        g2.setStroke(new BasicStroke(15.0f));
        g2.drawOval(90, 40, 55, 80);


        BufferedImage buffer = new BufferedImage(10, 10,
                BufferedImage.TYPE_INT_RGB);
        g2.setPaint(new TexturePaint(buffer, new Rectangle(10,10)));
        Graphics2D baru = buffer.createGraphics();
        baru.setColor(Color.BLUE);
        baru.fillRect(0, 0, 4, 4);
        baru.setColor(Color.yellow);
        baru.fillOval(0, 0, 10, 10);
        int a[] = {330, 370, 440};
        int b[] = {40, 160, 40};


        g.fillPolygon(a,b,3);
    }
    public static void main(String[] args) {
        JFrame frame = new JFrame( "Drawing Arcs" );
        frame.addWindowListener( new WindowAdapter(){
            @Override
            public void windowClosing( WindowEvent e ){
                System.exit( 0 );
            }
        });
        frame.setLayout(new BorderLayout());
        DrawingArcs draw = new DrawingArcs();
        frame.add(draw,BorderLayout.CENTER);
        frame.setSize( 450, 250 );
        frame.setVisible(true);
    }
}

Get This Comment Form

0 comment(s):

 
Copyright© 2010 | http://felisitasisme.com