如何解决类 Circle javafx.scene.shape.* 中的构造函数 Circle 的问题;
我正在尝试从标准 javafx.scene.shape 创建一个简单的圆。 * 班级。当我尝试编译程序时,我收到以下错误消息。我正在使用 Java 8.291! 我尝试用一个参数创建一个圆圈,但错误消息告诉我不需要参数。
test2.java:33: error: constructor Circle in class Circle cannot be applied to given types;
Circle circleA = new Circle(20);
^
**required: no arguments
found: int**
reason: actual and formal argument lists differ in length
test2.java:35: error: no suitable method found for addAll(Circle)
rootNode.getChildren().addAll(circleA);
^
method Collection.addAll(Collection<? extends Node>) is not applicable
(argument mismatch; Circle cannot be converted to Collection<? extends Node>)
method List.addAll(Collection<? extends Node>) is not applicable
(argument mismatch; Circle cannot be converted to Collection<? extends Node>)
method ObservableList.addAll(Node...) is not applicable
(varargs mismatch; Circle cannot be converted to Node)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
import javafx.application.*;
import javafx.scene.*;
import javafx.stage.*;
import javafx.scene.layout.*;
import javafx.geometry.*;
import javafx.scene.transform.*;
import javafx.scene.shape.*;
public class test2 extends Application{
public static void main(String[] args){
// Start the JavaFX application by calling launch().
launch(args);
}
// Override the start() method.
public void start(Stage myStage){
myStage.setTitle("Transformer");
FlowPane rootNode = new FlowPane(40,40);
rootNode.setAlignment(Pos.CENTER);
Scene myScene = new Scene(rootNode,500,200);
myStage.setScene(myScene);
Circle circleA = new Circle(20);
rootNode.getChildren().addAll(circleA);
myStage.show();
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。