Java代写 | 4483/8995 Software Technology Assignment Part2

本次澳洲作业案例分享是Advanced/Further Programming的一个编程代写Lab

1. Complete the program below to compute the area of a rectangle as shown below. If the
input values are non-numeric, print an appropriate error message

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class ComputeArea extends Application {
@Override
public void start(Stage primaryStage) {

GridPane pane = new GridPane();
pane.setAlignment(Pos.CENTER);
pane.setPadding(new Insets(11.5, 12.5, 13.5, 14.5));
pane.setHgap(10);
pane.setVgap(10);

// Your code goes here

Scene scene = new Scene(pane, 300, 200);

primaryStage.setTitle(“Calculate Area”);
primaryStage.setScene(scene);
primaryStage.show();

}

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

2. Complete the program below to drag the text “DRAG ME” to the text “DROP HERE” and
replace the text with “DRAG ME”.

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class DragAndDropDemo extends Application {

@Override
public void start(Stage stage) {
stage.setTitle(“Drag And Drop”);

Group root = new Group();
Scene scene = new Scene(root, 400, 200);
scene.setFill(Color.LIGHTGREY);

final Text source = new Text(50, 100, “DRAG ME”);
source.setScaleX(1.5);
source.setScaleY(1.5);

final Text target = new Text(250, 100, “DROP HERE”);
target.setScaleX(1.5);
target.setScaleY(1.5);

// Your code goes here

root.getChildren().add(source);
root.getChildren().add(target);
stage.setScene(scene);
stage.setResizable(false);
stage.show();
}

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

3. Write a program to choose an image from the desktop and display the image. Note “Clear”
option is only shown when there is an image displayed. You are required to use Scene
Builder to generate the FXML file.