效果图
代码:
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Line;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Chapter_14_3 extends Application {
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage primaryStage) throws Exception {
Group rootNode = new Group();
//椭圆
//前两个参数表示在面板中的位置 200表示x轴,100表示的y轴,
//后两个参数表示椭圆的长轴与短轴
Ellipse ellipse = new Ellipse(200,100,100,30);
ellipse.setStroke(Color.BLACK);
ellipse.setFill(Color.WHITE);
ellipse.setStrokeWidth(2);
//弧线
//前两个参数表示位置
//紧接着两个参数表示弧线长轴与短轴(可以使用Arc画椭圆)
//最后两个参数表示弧线的起始角度,与覆盖角度
Arc arc = new Arc(200,200,100,40,180,180);
arc.setFill(Color.WHITE);//设置填充颜色
arc.setStroke(Color.BLACK);//设置画笔颜色
arc.setType(ArcType.ROUND);
arc.setStrokeWidth(2);//设置画笔宽度
//直线--左
Line linel = new Line(100,100,100,200);
linel.setFill(Color.WHITE);
linel.setStroke(Color.BLACK);
linel.setStrokeWidth(2);
//直线--右
Line liner = new Line(300,100,300,200);
liner.setFill(Color.WHITE);
liner.setStroke(Color.BLACK);
liner.setStrokeWidth(2);
//文字--中
Text text = new Text("数据库");
text.setX(180);
text.setY(160);
rootNode.getChildren().setAll(ellipse,arc,linel,liner,text);
Scene scene = new Scene(rootNode,400,400);
primaryStage.setScene(scene);
primaryStage.show();
}
}