Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training Big Data and Hadoop Training Java Training  

drwapolyline() and drawOval()



Share on Google+Share on Google+

drwapolyline() and drawOval()
1 Answer(s)      6 years and 6 months ago
Posted in : Java Beginners

Explain drwapolyline() and drawOval() Methods with suitable example.

View Answers

February 22, 2011 at 3:13 PM

Java drwapolyline() and drawOval()

The method drawPolyline draws a sequence of connected lines defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point. The figure is not closed if the first point differs from the last point.

The method drawOval() draws the outline of an oval. The result is a circle or ellipse.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class DrawShapes extends JPanel{
    public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    int[] x = {25, 75, 125, 85, 125, 75, 25, 65};
      int[] y = {50, 90, 50, 100, 150, 110, 150, 100};
    g2d.drawPolyline(x,y,8 );
    g2d.drawOval(150,50,100,100 );

    public static void main(String s[]) {
    JFrame frame = new JFrame();
    frame.getContentPane().add(new DrawShapes());
    frame.setSize(300, 200);;