line.toBack()
line.toFront()
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
import javafx.stage.Stage;
public class LineUnderCircle extends Application {
@Override
public void start(Stage stage) throws Exception {
Line line = new Line(10, 10, 50, 50);
line.setStrokeWidth(3);
Circle left = new Circle(10, 10, 8, Color.FORESTGREEN);
Circle right = new Circle(50, 50, 8, Color.FIREBRICK);
Button lineToBack = new Button("Line to back");
lineToBack.setOnAction(e -> line.toBack());
Button lineToFront = new Button("Line to front");
lineToFront.setOnAction(e -> line.toFront());
Pane shapePane = new Pane(line, left, right);
HBox controlPane = new HBox(10, lineToBack, lineToFront);
VBox layout = new VBox(10, controlPane, shapePane);
layout.setPadding(new Insets(10));
stage.setScene(new Scene(layout));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
'line.toBack()は'働いていた(または単にグループに行を追加しているはずのいずれか最初に追加するか、 'add(0、line)'で追加してください)、[mc ve]。 – jewelsea
@ jewelsea - 何らかの理由で、line.toBack()が機能しません。私はmcvの例を提供する方法を見ていきますが、ここで簡単な要約です。私は私のサークルを描き、グループに追加します。次に、私は円と同じペインに線を描画し、同じグループに線を追加し、line.toBack()を適用します。 – Ulkurz
@ jewelsea - ありがとう、私は実際にそれを理解した、次回私はmvceを提供することを確認します。 :) – Ulkurz