javafx - 类 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();
}
}
解决方案
推荐阅读
- ios - 当我们使用 CoreData 、 UserDefaults 、 Keychain
- ios - 如何解决应用验证“应用引用 Payload/MyApp.app/MyApp:_setAlwaysRunsAtForegroundPriority: 中的非公共选择器”?
- sql - 检查表中的重复记录
- java - Spring - 将 HttpHeaders 与 @RequestHeaders 一起使用时出现空指针异常
- r - R igraph with multiple edges
- python - 使用 Mystic 的差分进化函数时参数值的界限不正确
- python - Extracting info from logs with timestamp
- jquery - 排序项的方法 asc & desc
- c++ - Accessing Private function using virtual function
- python - How can I avoid having PyQT5 Central Widget covering up MenuBar?