import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.shape.Line;
import javafx.stage.Stage;
public class LinesTest extends Application {
@Override
public void start(Stage stage) throws Exception {
final AnchorPane root = new AnchorPane();
final Line line1 = new Line(20, 10, 300, 10);
final Line line2 = new Line(250, 10, 400, 10);
root.getChildren().addAll(line1, line2);
stage.setTitle("Lines Test");
stage.setScene(new Scene(root, 500, 500));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
如果您运行上面的代码,您可能会提到重叠的两条线会创建另一种颜色。是否可以防止这种行为?