Question
Rewrite the program below in JavaFX. Do not use Circle object, you need to draw the circle pixle by pixel. import java.awt.*; import javax.swing.JFrame; public
Rewrite the program below in JavaFX.
Do not use Circle object, you need to draw the circle pixle by pixel.
import java.awt.*;
import javax.swing.JFrame;
public class L5_Midpoint_circle {
public static void main(String[] args) { System.out.print("Enter the radius of the circle(less than 300):"); java.util.Scanner input = new java.util.Scanner(System.in); MCircle circle = new MCircle(input.nextInt()); JFrame frame = new JFrame("MCircle"); frame.setSize(800, 800); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); circle.setPreferredSize(new Dimension(600,600)); frame.add(circle); frame.pack(); frame.setVisible(true); } }
package l5_midpoint_circle;
import java.awt.image.*; import javax.swing.JApplet; import java.awt.*;
public class MCircle extends JApplet { BufferedImage image = new BufferedImage(600, 600, BufferedImage.TYPE_INT_ARGB); WritableRaster raster = image.getRaster(); int r; MCircle(int r){ this.r = r; init(); } public void init() { setSize(600, 600); repaint(); } public void paint(Graphics g) { int []color = {255, 0, 0, 255}; int c = 600/2; int p0 = 1 - r; int x0 = 0; int y0 = r; int pk = p0; int x = x0; int y = y0; raster.setPixel(c, c+y, color); raster.setPixel(c, c-y, color); raster.setPixel(c+x, c, color); raster.setPixel(c-x, c, color); while (x
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started