JavaFX多边形折线
多边形,一个简单的示例代码如下所示 -
import javafx.application.Application
import javafx.scene.Group
import javafx.scene.Scene
import javafx.scene.shape.Polygon
import javafx.stage.Stage
public class Main extends Application {
// create w w W. y II b Ai .c o M
@Override
public void start(Stage stage) {
Group root = new Group()
Scene scene = new Scene(root, 260, 80)
stage.setScene(scene)
Group g = new Group()
Polygon polygon = new Polygon()
polygon.getPoints().addAll(new Double[]{
0.0, 0.0,
20.0, 10.0,
10.0, 20.0 })
g.getChildren().add(polygon)
scene.setRoot(g)
stage.show()
}
public static void main(String[] args) {
launch(args)
}
}
上面的代码生成以下结果。
折线示例,一个简单的示例代码如下所示 -
import javafx.application.Application
import javafx.scene.Group
import javafx.scene.Scene
import javafx.scene.shape.Polyline
import javafx.stage.Stage
// copyright wWW .Y II b Ai .c O m
public class Main extends Application {
@Override
public void start(Stage stage) {
Group root = new Group()
Scene scene = new Scene(root, 260, 80)
stage.setScene(scene)
Group g = new Group()
Polyline polyline = new Polyline()
polyline.getPoints().addAll(new Double[]{
0.0, 0.0,
20.0, 10.0,
10.0, 20.0 })
g.getChildren().add(polyline)
scene.setRoot(g)
stage.show()
}
public static void main(String[] args) {
launch(args)
}
}
上面的代码生成以下结果。