Java expert please help me out the Java program below. Here is a simple requirem
ID: 3822480 • Letter: J
Question
Java expert please help me out the Java program below. Here is a simple requirement, you can build the program base on your idea.
Need a Java class store animal data in the array list.
+Auto generate AnimalID base on hit add button on GUI.
+AnimalName (user input name of animals)
+Class of AnimalType store data mammals, birds, fish, reptiles, amphibians. User pick one of 5 Animal Types
+Class of AnimalRegion store data Africa, Aviary, and NorthAmerica. User pick one of 3 Animal Region
Another class can Add, Remove, or Update animal data, that bases on animal ID
You can build Graphical user interface (GUI) base on JavaFX but using Swing is fine too.
Here is an idea of GUI
Textbox Animal ID Field Animal Name Field Animal Type Dropbox Field mammals birds fish reptiles amphibians Animal Region Dropbox Field Africa Aviary North America Add Button Auto generate Animal ID, and add Animal Name, Animal Type, and Animal Region into array list. And show the animal inside the display box Update Button Add Button Remove Button Animal ID I Animal Name IAnimal Type I Animal Region Elephant mammals Africa -H Remove an animal base on Animal ID Update an animal base on Animal ID List all animals from array list.Explanation / Answer
I have given an layout to the particular program you asked for but it is only limited to birds and animals but for the rest the logic remains same and you can manipulate or optimize rest of the code by looking at this code
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
public class AnimalClassifier extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Animal Classification Based on GUI");
BorderPane componentLayout = new BorderPane();
componentLayout.setPadding(new Insets(20,0,20,20));
final FlowPane chPane = new FlowPane();
chPane.setHgap(100);
Label chlbL = new Label("Animals");
chBOX animals = new chBOX(FXCollections.observableArrayList("Dog", "Cat", "Rabbit", "Frog"
, "Panda", "Alligator", "Crocodile", "Tiger", "Lion"
, "Bear", "PolarBear", "Jaguar", "Slither", "Sycus"
, "Monkey"));
chPane.getChildren().add(chlbL);
chPane.getChildren().add(animals);
componentLayout.setTop(chPane);
final FlowPane listPane = new FlowPane();
listPane.setHgap(100);
Label listLbl = new Label("Birds");
ListView birds = new ListView(FXCollections.observableArrayList("Pigeon", "Parrot", "Crow"
,"Sparrow", "Peacock", "peahen", "Kiwi", "Flamingo", "Kingfisher"));
listPane.getChildren().add(listLbl);
listPane.getChildren().add(birds);
listPane.setVisible(false);
componentLayout.setCenter(listPane);
Button animBird = new Button("Animals or Birds");
animBird.setOnAction(new EventHandler() {
@Override
public void handle(ActionEvent event) {
//switch the visibility for each FlowPane
chPane.setVisible(!chPane.isVisible());
listPane.setVisible(!listPane.isVisible());
}
});
componentLayout.setBottom(animBird);
Scene appScene = new Scene(componentLayout,500,500);
primaryStage.setScene(appScene);
primaryStage.show();
}
}
Hope it helps....
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.