Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a GUI on java that looks like Including this in the project import javafx.collections.ObservableList; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Polygon; public class UpdateablePolygon extends

Create a GUI on java that looks like
Including this in the project
import javafx.collections.ObservableList;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;
public class UpdateablePolygon extends StackPane {
private int sides;
private double radius;
public int getSides(){
return this.sides;
}
public double getRadius(){
return this.radius;
}
public UpdateablePolygon(){
//this.setPrefSize(125,125);
this.radius =100;
this.paint();
//this.setStyle("-fx-border-color: black");
}
public void setSides(int sides){
if (sides >2){
this.sides = sides;
this.paint();
}
}
private void paint(){
this.getChildren().clear();
double centerX = this.getWidth()/2;
double centerY = this.getHeight()/2;
Polygon poly = new Polygon();
poly.setFill(Color.WHITE);
poly.setStroke(Color.BLACK);
ObservableList list = poly.getPoints();
// Add points to the polygon list
for (int i =0; i this.sides; i++){
list.add(centerX + this.radius * Math.cos(2* i * Math.PI / this.sides));
list.add(centerY - this.radius * Math.sin(2* i * Math.PI / this.sides));
}
this.getChildren().add(poly);
}
}
image text in transcribed

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

Statistical And Scientific Database Management International Working Conference Ssdbm Rome Italy June 21 23 1988 Proceedings Lncs 339

Authors: Maurizio Rafanelli ,John C. Klensin ,Per Svensson

1st Edition

354050575X, 978-3540505754

More Books

Students also viewed these Databases questions