import
javafx.application.Application;
import
javafx.scene.Scene;
import
javafx.scene.shape.DrawMode;
import
javafx.scene.layout.*;
import
javafx.event.ActionEvent;
import
javafx.scene.AmbientLight;
import
javafx.scene.shape.Sphere;
import
javafx.scene.control.*;
import
javafx.stage.Stage;
import
javafx.scene.Group;
import
javafx.scene.PerspectiveCamera;
import
javafx.scene.paint.Color;
import
javafx.event.ActionEvent;
import
javafx.event.EventHandler;
public
class
ambient_light_2
extends
Application {
public
void
start(Stage stage)
{
stage.setTitle(
"creating ambient_light"
);
Sphere sphere =
new
Sphere(
80
.0f);
AmbientLight ambient_light =
new
AmbientLight(Color.RED);
Button button =
new
Button(
"light"
);
Group group =
new
Group(sphere, ambient_light, button);
sphere.setTranslateX(
100
);
sphere.setTranslateY(
100
);
EventHandler<ActionEvent> event =
new
EventHandler<ActionEvent>() {
public
void
handle(ActionEvent e)
{
ambient_light.setLightOn(!ambient_light.isLightOn());
}
};
button.setOnAction(event);
Scene scene =
new
Scene(group,
500
,
300
);
stage.setScene(scene);
stage.show();
}
public
static
void
main(String args[])
{
launch(args);
}
}