Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Programming: You are given one JPanel DrawArcs.java(Fan). Use your own thread to give them a life that means make the Fan To start. Use

Java Programming: You are given one JPanel DrawArcs.java(Fan). Use your own thread to give them a life that means make the Fan To start. Use your own GUI to start and stop as you wish. Do it in swing.

import javax.swing.JFrame;

import javax.swing.JPanel;

import java.awt.Graphics;

public class DrawArcs extends JFrame {

public DrawArcs() {

setTitle("DrawArcs");

add(new ArcsPanel());

}

/** Main method */

public static void main(String[] args) {

DrawArcs frame = new DrawArcs();

frame.setLocationRelativeTo(null); // Center the frame

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setSize(250, 300);

frame.setVisible(true);

}

}

// The class for drawing arcs on a panel

class ArcsPanel extends JPanel {

@Override

protected void paintComponent(Graphics g) {

super.paintComponent(g);

int xCenter = getWidth() / 2;

int yCenter = getHeight() / 2;

int radius = (int)(Math.min(getWidth(), getHeight()) * 0.4);

int x = xCenter - radius;

int y = yCenter - radius;

g.fillArc(x, y, 2 * radius, 2 * radius, 0, 30);

g.fillArc(x, y, 2 * radius, 2 * radius, 90, 30);

g.fillArc(x, y, 2 * radius, 2 * radius, 180, 30);

g.fillArc(x, y, 2 * radius, 2 * radius, 270, 30);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions

Question

=+from: a) a MNEs perspective? and b) the HRM managers perspective?

Answered: 1 week ago