Question: Using Java JCreator: Correct the code below import java.awt.Graphics; import java.awt.Polygon; import java.swing.JPanel; import java.swing.JFrame; class SpiralDemo extends JPanel { public void paintComponent(Graphics g) {

Using Java JCreator: Correct the code below

import java.awt.Graphics;

import java.awt.Polygon;

import java.swing.JPanel;

import java.swing.JFrame;

class SpiralDemo extends JPanel

{

public void paintComponent(Graphics g)

{

super.paintComponent(g);

int[] x =

{

150, 235, 265, 228, 150, 79, 55, 86,

150, 207, 225, 199, 150, 108, 95, 155

150, 178, 185, 171, 150, 136, 135, 143

150 };

int [] y =

{

275, 235, 150, 72, 45, 79, 150, 214,

235, 207, 150, 101, 85, 108, 150, 185,

195, 178, 150, 129, 125, 136, 150, 157,

155 };

g.drawPolyline(x,y,19);

}

}

class Spiral extends JFrame

{

public static void main(String[] args)

{

JFrame frame = new JFrame ("Spiral");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

SpiralDemo application = new SpiralDemo();

frame.add(application);

frame.setSize(350, 350);

frame.setVisible(true);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!