我正在启动JavaFx,我想为我的圈子指定填充和轮廓,我很快找到了setFill()和setStroke()函数,但是我的Eclipse不理解它们,所以我找不到原因!
我的代码:
package application;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
public class Main extends Application {
Circle cercle = new Circle(100,100,75);
cercle.setFill(Color.YELLOW);
cercle.setStroke(Color.ORANGE);
@Override
public void start(Stage primaryStage) {
try {
BorderPane root = new BorderPane();
Scene scene = new Scene(root,800,600, Color.YELLOW);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
添加
import javafx.scene.shape.Line.*
到代码的开头