GTU OOP Program - 19

19). Write a program that displays the color of a circle as red when the mouse button is pressed and as white when the mouse button is released.

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class Program_19 extends Application {

    @Override
    public void start(Stage primaryStage) {
        double width = 400;
        double height = 400;
        Circle c = new Circle(width / 2, height / 2, Math.min(width, height) / 10, Color.WHITE);

        c.setStroke(Color.BLACK);

        StackPane pane = new StackPane(c);

        primaryStage.setScene(new Scene(pane, width, height));
        pane.setOnMousePressed(e -< c.setFill(Color.RED));
        pane.setOnMouseReleased(e -< c.setFill(Color.WHITE));
        primaryStage.setTitle("Click on the window");
        primaryStage.show();
    }

    public static void main(String[] args) {
        Application.launch(args);
    }
}
Output

gtu oop lab manual,

oop GTU Practical,

oop Programs,

Object oriented Programming,

Gtu study material 3140705,

OOP 3140705,

oop practical list,

Java Programming,

gtu oop practical,

oop lab solution gtu

Comments

YouTube

Popular posts from this blog

GTU OOP Program - 21

GTU OS Program - 3

GTU OOP Program - 1