Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package light;
- import javafx.application.*;
- import javafx.util.*;
- import javafx.scene.shape.*;
- import javafx.geometry.*;
- import javafx.scene.*;
- import javafx.stage.Stage;
- import java.awt.Color;
- import javafx.*;
- public class Traffic_light {
- public void start(Stage pStage) {
- Pane pane = new Pane();
- Circle redLight = new Circle(paneWidth/2,30,12);
- Circle yellowLight = new Circle(paneWidth/2,60,12);
- Circle greenLight = new Circle(paneWidth/2,90,12);
- redLight.setStroke(Color.BLACK);
- redLight.setFill(Color.WHITE);
- yellowLight.setStroke(Color.BLACK);
- yellowLight.setFill(Color.WHITE);
- greenLight.setStroke(Color.BLACK);
- greenLight.setFill(Color.WHITE);
- Rectangle rect = new Rectangle(paneWidth /2,-25,5,30,100);
- rect.setStroke(Color.BLACK);
- rect.setFill(Color.BEIGE);
- pane.getChildren.addAll(rect, redLight, yellowLight, greenLight);
- Scene scene = new Scene(pane,paneWidth,paneHeight);
- pstage.setTitle("Traffic Light");
- pStage.setScene(scene);
- pStage.show();
- }
- public static void main(String[] args) {
- Launch(args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement