Java Programming Lab Assignment - 5
Java Programming Lab Assignment - 5
LAB ASSIGNMENT – 5
CODE –
package LabTask5_17BIS0020;
import java.util.Arrays;
}
OUTPUT -
CODE –
Package Labtask5_17BIS0020;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.*;
import javafx.scene.control.Label;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.canvas.*;
import javafx.scene.web.*;
import javafx.scene.layout.*;
import javafx.scene.image.*;
import java.io.*;
import javafx.geometry.*;
import javafx.scene.Group;
import javafx.scene.paint.*;
@Override
public void start(Stage primaryStage) {
Button btn1 = new Button();
btn1.setText("Red");
btn1.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
BackgroundFill background_fill = new
BackgroundFill(Color.RED,
CornerRadii.EMPTY, Insets.EMPTY);
btn1.setBackground(background);
System.out.println("Red");
}
});
btn2.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
BackgroundFill background_fill = new
BackgroundFill(Color.GREEN,
CornerRadii.EMPTY, Insets.EMPTY);
btn2.setBackground(background);
System.out.println("Green");
}
});
btn3.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
BackgroundFill background_fill = new
BackgroundFill(Color.BLUE,
CornerRadii.EMPTY, Insets.EMPTY);
btn3.setBackground(background);
System.out.println("Blue");
}
});
btn4.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
BackgroundFill background_fill = new
BackgroundFill(Color.PINK,
CornerRadii.EMPTY, Insets.EMPTY);
btn4.setBackground(background);
System.out.println("Pink");
}
});
btn5.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
BackgroundFill background_fill = new
BackgroundFill(Color.BLACK,
CornerRadii.EMPTY, Insets.EMPTY);
btn5.setBackground(background);
System.out.println("Black");
}
});
primaryStage.setTitle("Labtask5_17BIS0020");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
OUTPUT –