Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In specifically JavaFX write a program to display a phone book. the phonebook sh

ID: 3720097 • Letter: I

Question

In specifically JavaFX write a program to display a phone book.

the phonebook should have 5 types of entries.

A first and last name entry each up to 8 characters long.

A phone entry that uses the String pattern = "^\(?(\d{3})?\)?[- ]?(\d{3})[- ](\d{4})$";
and doesn't allow other entries. There should also only be 1 contact allowed per a phone number.

all three of the above cannot be left blank.

next is an email address which can be filled in with a proper email address or left blank.

last is a notes entry, which can be left blank.

there should be a list button to show all entries.

an add button to insert a new entry.

A delete button to remove an unwanted entry .

an edit button to edit an existing entry.

A sort button to sort the list by recently added, alphabetical order, and phone numbers.

A merge button that allows the user to merge a duplicate contact and add their phone number and notes to the first entries notes.

A search button to find a given contact by any known field

And lastly a quit button that will store the whole file to memory, so that the contacts will still be there when the program is reopened.

The GUI will be judged on aesthetics and functionality.

Explanation / Answer


JavaFXPhonebook:
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.ContextMenuEvent;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class JavaFXPhonebook extends Application {
  

public void start(final Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
stage.initStyle(StageStyle.TRANSPARENT);
Scene scene = new Scene(root);
scene.setFill(Color.TRANSPARENT);
stage.setScene(scene);
stage.show();
root.setOnMouseClicked(new EventHandler<MouseEvent>(){
public void handle(MouseEvent t) {
Parent root1 = null;
try {
root1 = FXMLLoader.load(getClass().getResource("SatrtNew.fxml"));
} catch (IOException ex) {
Logger.getLogger(JavaFXApplication13.class.getName()).log(Level.SEVERE, null, ex);
}
Stage stage1= new Stage();
stage1.initStyle(StageStyle.TRANSPARENT);
Scene scene1 = new Scene(root1);
scene1.setFill(Color.TRANSPARENT);
stage1.setScene(scene1);
stage1.show();
stage.close();

}
});
}
public static void main(String[] args) {
launch(args);
}
}
SampleController:
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class SampleController implements Initializable {
  

private AnchorPane anchorPane;
private Text text;
private Text text2;

private void StartNew(KeyEvent event) throws IOException {
Parent rootSearch = FXMLLoader.load(getClass().getResource("SatrtNew.fxml"));
Stage stageStart = new Stage();
stageStart.initStyle(StageStyle.TRANSPARENT);
Scene sceneStart = new Scene(rootSearch);
stageStart.setScene(sceneStart);
stageStart.show();
anchorPane.getScene().getWindow().hide();
}
  
  
  
public void initialize(URL url, ResourceBundle rb) {
// TODO
}   
}

SatrtNewController:
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.Window;

public class SatrtNewController implements Initializable {
private Button entry;

private Button search;
private Button exitButton;
private AnchorPane anchorPaneStart;
private void entryEvent(ActionEvent event) throws IOException {
Parent rootEntry = FXMLLoader.load(getClass().getResource("Entry.fxml"));
Stage stageEntry = new Stage();
stageEntry.initStyle(StageStyle.TRANSPARENT);
Scene sceneEntry = new Scene(rootEntry);
stageEntry.setScene(sceneEntry);
stageEntry.show();
  
}
private void searchEvent(ActionEvent event) throws IOException {
Parent rootSearch = FXMLLoader.load(getClass().getResource("Search.fxml"));
Stage stageSearch = new Stage();
stageSearch.initStyle(StageStyle.TRANSPARENT);
Scene sceneSearch = new Scene(rootSearch);
stageSearch.setScene(sceneSearch);
stageSearch.show();
  
}
private void exitEvent(ActionEvent event) throws IOException {

System.exit(0);
}
  
  

public void initialize(URL url, ResourceBundle rb) {
// TODO

}   
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote