用javafx画一个黄色的气球
时间: 2023-10-23 20:08:25 浏览: 34
好的,以下是JavaFX代码实现:
```java
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
public class Balloon extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
// 创建一个圆形
Circle circle = new Circle(50, Color.YELLOW);
circle.setStroke(Color.BLACK); // 设置边框颜色
circle.setStrokeWidth(2); // 设置边框宽度
// 将圆形添加到面板中
Pane root = new Pane(circle);
// 创建场景并设置到舞台中
Scene scene = new Scene(root, 200, 200);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
```
运行后,会显示一个黄色的圆形,就像一个气球一样。