This application will write & read a CSV file to your C drive
The folder A_Hospital is created and the file Patients.csv is also created
You will need to delete the folder after testing the application.
The application is built with FXML and uses the TableView control as
well as how to use a module Stage as a dialog. Code also uses a listener
to display information about the row selected in the TableView
I have included a lot of input validation
Also the use of an observableArrayList and ArrayList to contain the
CSV file data. Some minor css code to style the TableView
I hope you enjoy the code
Main Class
package appCT;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.fxml.FXMLLoader;
public class CTVMain extends Application {
@Override
public void start(Stage pStage) {
try {
AnchorPane root = (AnchorPane)FXMLLoader.load(getClass().getResource("ctv.fxml"));
Scene scene = new Scene(root,1040,650);
pStage.setScene(scene);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
pStage.setResizable(false);
pStage.setTitle("Table Demo with Read/Write CSV file CRUD and CSS style code");
pStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
Controller Class
package appCT;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Optional;
import java.util.ResourceBundle;
import java.util.Scanner;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.stage.FileChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class CTVController implements Initializable {
@FXML private Pane pane;
@FXML private TextField txfHospNum;
@FXML private TextField txfFName;
@FXML private TextField txfLName;
@FXML private TextField txfRoomNum;
@FXML private TextField txfHospNum1;
@FXML private TextField txfFName1;
@FXML private TextField txfLName1;
@FXML private TextField txfRoomNum1;
@FXML public TableView<Person> table;
@FXML public TableColumn <Person,String> firstNameCol;
@FXML public TableColumn <Person,String> lastNameCol;
@FXML public TableColumn <Person,String> hospitalNumCol;
@FXML public TableColumn <Person,String> roomNumCol;
@FXML private Button btnLoad;
public ObservableList<Person> TableData;
public ArrayList<Contacts> list;
FileChooser fc = new FileChooser();
private Scanner scan;
private int i;
Boolean NO = true;
@FXML
private void onEdit(ActionEvent e) throws IOException{
i = table.getSelectionModel().getSelectedIndex();
if(i==-1) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Information");
alert.setHeaderText("");
alert.setContentText("No Record Selected to EDIT\n"+
"\nClick the Table Row to Select the Record to Edit\n"+
"\nChange Information then Alt+ E to SAVE the Edit");
alert.showAndWait();
return;
}else {
NO = false;
onSave(e);
onRemove(e);
}
}
// REMOVE Method <---------------------------------------------------
@FXML//This code removes data from the ArrayList and RE-Writes to the
//People.csv file the file is deleted first then rewritten from the list ArrayList<Contacts>
private void onRemove(ActionEvent e)throws IOException{
if(txfHospNum.getText().isEmpty()||txfFName.getText().isEmpty()||txfLName.getText().isEmpty()||txfRoomNum.getText().isEmpty()) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Information");
alert.setHeaderText("");
alert.setContentText("No Record Selected to REMOVE\n"+
"Click the Table Row to Select the Record to Delete");
alert.showAndWait();
return;
}
i = table.getSelectionModel().getSelectedIndex();
//boolean t = table.getSelectionModel().isSelected(i);
list.get(i);
list.remove(i);
TableData.remove(i);
//===================
if(0 == list.size()){
Path path = FileSystems.getDefault().getPath("C:/A_Hospital", "Patients.csv");
Files.delete(path);
txfHospNum.setText("");
txfFName.setText("");
txfLName.setText("");
txfRoomNum.setText("");//Used with last record in file ONLY
return;
}else if(i == list.size()){
i = i - 1;
}
Contacts p = list.get(i);
getContacts(p);
Contacts dat;
for(int r = 0; r <list.size(); r++){
dat = list.get(r);
}
Path path = FileSystems.getDefault().getPath("C:/A_Hospital", "Patients.csv");
Files.delete(path);//Deletes csv file
File file = new File("C:/A_Hospital/Patients.csv");
if(!(file.exists())){
file.createNewFile();//Creates new csv file
}
FileWriter fileWriter = new FileWriter(file.getPath(),true);
BufferedWriter bufferWritter = new BufferedWriter(fileWriter);
Iterator<Contacts> LIT = list.iterator();
while(LIT.hasNext()) {
dat = LIT.next();
String d = dat.toString();
bufferWritter.write(d);
}
bufferWritter.close();
onClear(e);// onClear(e) has the lines of code below included
// it re-populates the Observable ArrayList TableData
// and adds the TableData to the table and shows the table
// with a call to the method onShowTableData();
/*table.getItems().clear();//Clears the table
Path dirP = Paths.get(String.valueOf(file));
InputStream in = Files.newInputStream(dirP);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
scan = new Scanner(reader);
scan.useDelimiter("\\s*,\\s*");
while (scan.hasNext()){
String hospnum = scan.next();
String fname = scan.next();
String lname = scan.next();
String roomnum = scan.next();
TableData.add(new Person(hospnum,fname,lname,roomnum));
table.setItems(TableData);
onShowTableData();
}
scan.close();*/
}
@FXML//Initialize a listener for the selection of a ROW in the table
private void Init() {
showPersonDetails(null);
table.getSelectionModel().selectedItemProperty().addListener((ov,oldValue, newValue)
-> showPersonDetails(newValue));
}
private void showPersonDetails(Person person) {
//Just TEST code I did not delete ?
/*if(table.isPressed()==true && TableData.size()>0) {*/
//TableViewSelectionModel<Person> tsm = table.getSelectionModel();
//ObservableList<Integer> list2 = tsm.getSelectedIndices();
//list2.addListener((ListChangeListener.Change<? extends Integer> change) -> {
//String m = String.valueOf(list2);
//System.out.println("Row selection has changed "+ m);
//});
//boolean t = table.getSelectionModel().isSelected(i);
//System.out.println(t +" "+ i +" below");
if (person != null ) {
Person who = table.getSelectionModel().getSelectedItem();
txfHospNum.setText(who.getHospitalNumber());
txfFName.setText(who.getFirstName());
txfLName.setText(who.getLastName());
txfRoomNum.setText(who.getRoomNumber());
txfHospNum.setEditable(true);
txfFName.setEditable(true);
txfLName.setEditable(true);
txfRoomNum.setEditable(true);
}else {
}
}
// SAVE Method <---------------------------------------
@FXML
private void onSave(ActionEvent e) throws IOException{
if(txfHospNum.getText().isEmpty() || txfFName.getText().isEmpty()
|| txfLName.getText().isEmpty() || txfRoomNum.getText().isEmpty()) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Information");
alert.setHeaderText("");
alert.setContentText("No DATA entered\n"+
"Alt + A to ENTER Data and Alt + S to SAVE");
alert.showAndWait();
if(txfFName.getText().isEmpty()) {
txfFName.requestFocus();
return;
}
if(txfLName.getText().isEmpty()) {
txfLName.requestFocus();
return;
}
if(txfHospNum.getText().isEmpty()) {
txfHospNum.requestFocus();
return;
}
if(txfRoomNum.getText().isEmpty()) {
txfRoomNum.requestFocus();
return;
}
return;
}
String regX1 = ("[a-zA-Z\\s\\^W]*");
String W1 = String.valueOf(txfFName.getText().trim());
if(!W1.matches(regX1) || W1.length() > 19){
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Information");
alert.setHeaderText("");
alert.setContentText("Alpha Characters Only\n"+
"and a Maximum of 19 Characters");
alert.showAndWait();
txfFName.setText(txfFName.getText().substring(0, 19));
txfFName.requestFocus();
return;
}
String regX2 = ("[a-zA-Z\\s\\^W]*");
String W2 = String.valueOf(txfLName.getText().trim());
if(!W2.matches(regX2) || W2.length() > 26){
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Information");
alert.setHeaderText("");
alert.setContentText("Alpha Characters Only\n"+
"and a Maximum of 26 Characters");
alert.showAndWait();
txfLName.setText(txfLName.getText().substring(0, 26));
txfLName.requestFocus();
return;
}
//String regX3 = ("[0-9\\^W]*");
String regX3 = ("^\\d{3}-\\d{3}");
String W3 = String.valueOf(txfHospNum.getText().trim());
if(!W3.matches(regX3) || W3.length() > 7 ) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Information");
alert.setHeaderText("");
alert.setContentText("Numeric Values Only\n"+
"Entry Patrern ###-###");
alert.showAndWait();
txfHospNum.setText(txfHospNum.getText().substring(0, 7));
txfHospNum.requestFocus();
return;
}
String regX4 = ("[0-9\\^W]*");
String W4 = String.valueOf(txfRoomNum.getText().trim());
if(!W4.matches(regX4)|| W4.length() > 3) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Information");
alert.setHeaderText("");
alert.setContentText("Numeric Values Only\n"+
"Maximum of 3 Digits");
alert.showAndWait();
txfRoomNum.setText(txfRoomNum.getText().substring(0, 3));
txfRoomNum.requestFocus();
return;
}
//Alert Do You Want to SAVE with a Confirmation Alert Dialog
Alert alert1 = new Alert(AlertType.CONFIRMATION);
alert1.setTitle("Confirm Save");
alert1.setHeaderText("");//Removes the header text
alert1.setContentText("Select OK to Save Data");
Optional<ButtonType> result = alert1.showAndWait();
if (result.get() != ButtonType.OK){//If Cancel is selected start over
onClear(e);
unAdd(e);
return;
}else {
String hospnum = txfHospNum.getText().trim();
String fname = txfFName.getText().trim();
String lname = txfLName.getText().trim();
String roomnum = txfRoomNum.getText().trim();
String data = (hospnum + "," + fname + "," + lname + "," + roomnum + "," + '\r');
list.add(new Contacts(hospnum,fname,lname,roomnum));
File dirPath = new File("C:/A_Hospital");
dirPath.mkdirs();//Make the directory
File file = new File(dirPath,"Patients.csv");
if(!file.exists()){
file.createNewFile();//Create and empty text file if it is not already created
}
FileWriter fileWriter = new FileWriter(file.getPath(),true);
try (BufferedWriter bufferWritter = new BufferedWriter(fileWriter)) {
bufferWritter.write(data);
}
//Alert that you did SAVE too many Alerts!
//This Can be removed
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Information Dialog");
alert.setHeaderText(null);
alert.setContentText("Data Saved");
alert.showAndWait();
//TableData.add(new Person(hospnum,fname,lname,roomnum));
//table.setItems(TableData);
//onShowTableData();
//Lines above adds new data to the table with SAVE
//-------------------------------------------------
//txfHospNum.setText("");
//txfFName.setText("");
//txfLName.setText("");
//txfRoomNum.setText("");
//txfFName.requestFocus();
if(NO == true) {//If it is NOT and EDIT then call onClear(e);
onClear(e);
}
unAdd(e);
//fileWriter.flush();
}
}
// LOAD Method <-----------------------------------------
//@FXML
//private void onLoad(ActionEvent e) throws IOException {
//Use the line of code above if you want to load with a click event
//you will also need to add a load function in the MenuBar
//As it is set NOW an Auto Load when the application starts
private void onLoad() throws IOException {
list = new ArrayList<Contacts>();
TableData = FXCollections.observableArrayList();
File fileInfo = new File("C:/A_Hospital/Patients.csv");
if(fileInfo.length()==0) {//commet out if you use the Alert below
// 20 lines of code to make a Custom Dialog
// You only need 7 lines of code to use a predefined Dialog
// If your a control freak go for it this is here for fun
// The little Infomation Dialog looked lonsome on the big screen ha ha
Label lblW = new Label("No Data in File at "+ fileInfo+"\n"+//commet out with Alert
"\nSelect File -> Add then Enter Data and Save");//commet out with Alert
Button btnOK = new Button("OK");//commet out with Alert
btnOK.setStyle("-fx-font-size:18;-fx-font-weight:bold");//commet out with Alert
lblW.setStyle("-fx-font-size:18;-fx-font-weight:bold");//commet out with Alert
btnOK.setLayoutX(400);//commet out with Alert
btnOK.setLayoutY(160);//commet out with Alert
lblW.setLayoutX(30);//commet out with Alert
lblW.setLayoutY(60);//commet out with Alert
//Stage stage = new Stage();
Stage stage = new Stage(StageStyle.UNDECORATED);
stage.initModality(Modality.WINDOW_MODAL);
Pane root = new Pane();
root.getChildren().addAll(lblW, btnOK);//commet out with Alert
Scene scene = new Scene(root, 500, 230);
root.setStyle("-fx-background:yellow");
stage.setX(390);
stage.setY(180);
btnOK.setOnAction(e -> stage.close());//commet out with Alert
//stage.setResizable(false);
//stage.setTitle("I am Yellow");
stage.setScene(scene);
stage.showAndWait();//commet out if you use the Alert below
//stage.show();//Need to USE if you use the Alert below
}
/*if(fileInfo.length()==0) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setX(425);
alert.setY(215);//This will place tha Alert in the middle of the modal STAGE
alert.setTitle("Information");
alert.setHeaderText("");
alert.setContentText("No Data in File at "+ fileInfo+"\n"+
"\nSelect File -> Add then Enter Data and Save");
alert.showAndWait();
stage.close();
return;
}*/
/*fc.setTitle("Load Contacts Info");//This is used with a manual load click event
fc.setInitialDirectory(new File("C:/"));
fc.setInitialDirectory(new File("C:/A_Hospital"));
fc.setInitialFileName("Patients.csv");
File file = fc.showOpenDialog(null);
if (file == null) {
return;
}
String correctFile = fileInfo.getName();//This is used with a manual load event
if(!(correctFile.matches("Patients.csv"))){//test to ensure correct file is loaded
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Information");
alert.setHeaderText("");
alert.setContentText("The File at " + fileInfo + "\n\n"+
"is NOT accociated with this application\n\n"+
"Select the File at "+fileInfo);
alert.showAndWait();
return;
}*/
Path dirP = Paths.get(String.valueOf(fileInfo));
InputStream in = Files.newInputStream(dirP);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
scan = new Scanner(reader);
scan.useDelimiter("\\s*,\\s*");//Removes the comma and white space
while (scan.hasNext()){
String hospnum = scan.next();
String fname = scan.next();
String lname = scan.next();
String roomnum = scan.next();
//Populate BOTH list Array List and observableArrayList TableData
list.add(new Contacts(hospnum,fname,lname,roomnum));
TableData.add(new Person(hospnum,fname,lname,roomnum));
table.setItems(TableData);
onShowTableData();
}
scan.close();
}
private void onShowTableData() {
hospitalNumCol.setCellValueFactory(cellData -> cellData.getValue().hospitalNumberProperty());
firstNameCol.setCellValueFactory(cellData -> cellData.getValue().firstNameProperty());
lastNameCol.setCellValueFactory(cellData -> cellData.getValue().lastNameProperty());
roomNumCol.setCellValueFactory(cellData -> cellData.getValue().roomNumberProperty());
}
//Model for Contacts Class
private void getContacts(Contacts p){
txfHospNum.setText(" " + p.getHNum());
txfFName.setText(" " + p.getFName());
txfLName.setText(" " + p.getLName());
txfRoomNum.setText(" " + p.getRNum());
}
@FXML
private void onAdd(ActionEvent e) {
txfHospNum.setEditable(true);
txfFName.setEditable(true);
txfLName.setEditable(true);
txfRoomNum.setEditable(true);
txfFName.requestFocus();
}
private void unAdd(ActionEvent e) {
txfHospNum.setEditable(false);
txfFName.setEditable(false);
txfLName.setEditable(false);
txfRoomNum.setEditable(false);
}
@FXML
private void onClear(ActionEvent e) throws IOException {
File file = new File("C:/A_Hospital/Patients.csv");
if(file.length()==0) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Information");
alert.setHeaderText("");
alert.setContentText("No Data in File at "+ file+"\n"+
"\nSelect File -> Add then Enter Data and Save");
alert.showAndWait();
txfFName.requestFocus();
return;
}
txfHospNum.setText("");
txfFName.setText("");
txfLName.setText("");
txfRoomNum.setText("");
txfFName.requestFocus();
// Code lines below re-populates the table from the Patients.csv file
//--------------------------------------------------------------------
table.getItems().clear();//Clears the table
File fileInfo = new File("C:/A_Hospital/Patients.csv");
Path dirP = Paths.get(String.valueOf(fileInfo));
InputStream in = Files.newInputStream(dirP);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
scan = new Scanner(reader);
scan.useDelimiter("\\s*,\\s*");
while (scan.hasNext()){
String hospnum = scan.next();
String fname = scan.next();
String lname = scan.next();
String roomnum = scan.next();
TableData.add(new Person(hospnum,fname,lname,roomnum));
table.setItems(TableData);
onShowTableData();
}
scan.close();
}
@FXML
private void onExit(ActionEvent e) {
System.exit(0);
}
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
Init();//Set Listiners
//These lines of code do nothing except make the
//table Column header css work in the css file
//I think this is BUG with the TableView API
hospitalNumCol.getStyleClass().add("top-left;");
firstNameCol.getStyleClass().add("top-left");
lastNameCol.getStyleClass().add("top-left;");
roomNumCol.getStyleClass().add("top-left;");
try {
onLoad();
} catch (IOException e) {
}
//Just Test Code ignore
//use for Edit with the table
// table.getSelectionModel().select(3);
}
}
Contacts Class
package appCT;
public class Contacts {
private String HNum;
private String FName;
private String LName;
private String RNum;
//public Contacts(String pFname, String pLname, String pPnum, String pEmail) {
//super();
//this.FName = pFname;
//this.LName = pLname;
//this.PNum = pPnum;
//this.EMail = pEmail;
//}
public Contacts(String pHnum,String pFname, String pLname, String pRnum){
HNum = pHnum;
FName = pFname;
LName = pLname;
RNum = pRnum;
}
@Override
public String toString(){
return HNum + "," +
FName + "," +
LName + "," +
RNum + "," + '\r' ;
}
public String toFile(){
return HNum + "," + FName + "," + LName + "," + RNum + "," +'\r';
}
public String getFName(){
return FName;
}
public String getLName(){
return LName;
}
public String getHNum(){
return HNum;
}
public String getRNum(){
return RNum;
}
}
Person Class
package appCT;
//This belongs to CTV Controller
//==============================
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
public class Person {
private final StringProperty hospitalNum = new SimpleStringProperty(this, "hospitalNum", null);
private final StringProperty firstName = new SimpleStringProperty(this, "firstName", null);
private final StringProperty lastName = new SimpleStringProperty(this, "lastName", null);
private final StringProperty roomNum = new SimpleStringProperty(this, "roomNum", null);
public Person() {
this(null, null, null,null);
}
public Person(String hospitalNum,String firstName, String lastName,String roomNum) {
this.hospitalNum.set(hospitalNum);
this.firstName.set(firstName);
this.lastName.set(lastName);
this.roomNum.set(roomNum);
}
/* firstName Property */
public final String getHospitalNumber() {//1
return hospitalNum.get();
}
public final void setHospitalNumber(String hospitalNum) {//1
hospitalNumberProperty().set(hospitalNum);
}
public final StringProperty hospitalNumberProperty() {//1
return hospitalNum;
}
public final String getFirstName() {//2
return firstName.get();
}
public final void setFirstName(String firstName) {//2
firstNameProperty().set(firstName);
}
public final StringProperty firstNameProperty() {//2
return firstName;
}
public final String getLastName() {//3
return lastName.get();
}
public final void setLastName(String lastName) {//3
lastNameProperty().set(lastName);
}
public final StringProperty lastNameProperty() {//3
return lastName;
}
public final String getRoomNumber() {
return roomNum.get();
}
public final void setRoomNumber(String roomNum) {
roomNumberProperty().set(roomNum);
}
public final StringProperty roomNumberProperty() {
return roomNum;
}
}
CSS code
.text-field{
-fx-font-weight:bold;
}
.table-view{
-fx-background-color: lightblue;
-fx-border-width: 3px;
-fx-border-color: black;
-fx-border-style: solid;
}
.table-row-cell {
-fx-font-size: 12pt;
-fx-font-weight:bold;
-fx-alignment:top-left;
}
.table-view .column-header .label{
-fx-font-size: 12pt;
-fx-text-fill: blue;
-fx-alignment:top-left;
}
.table-row-cell:selected {
-fx-background-color: blue;
}
.table-row-cell:selected .text {
/*-fx-background-color: black;*/
-fx-fill: red ;
}
.table-row-cell .table-cell {
-fx-text-fill: black;
-fx-border-width: 0.75px;
-fx-border-color: black black black black;
-fx-background-color: lightblue;
}
FXML File
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.input.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane prefHeight="650.0" prefWidth="1040.0"
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="appCT.CTVController">
<children>
<Pane fx:id="pane" prefHeight="650.0" prefWidth="1040.0"
style="-fx-background-color: tan;" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<children>
<MenuBar focusTraversable="false" style="-fx-background-color: tan;">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" onAction="#onAdd"
text="Add">
<accelerator>
<KeyCodeCombination alt="ANY" code="A"
control="UP" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#onSave"
text="Save">
<accelerator>
<KeyCodeCombination alt="ANY" code="S"
control="UP" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" onAction="#onRemove"
text="Delete">
<accelerator>
<KeyCodeCombination alt="ANY" code="D"
control="UP" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#onEdit"
text="Edit">
<accelerator>
<KeyCodeCombination alt="ANY" code="E"
control="UP" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#onClear"
text="Clear">
<accelerator>
<KeyCodeCombination alt="ANY" code="C"
control="UP" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" onAction="#onExit"
text="Exit">
<accelerator>
<KeyCodeCombination alt="ANY" code="X"
control="UP" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
</items>
</Menu>
</menus>
</MenuBar>
<Label focusTraversable="false" layoutX="50.0" layoutY="70.0"
text="First Name">
<font>
<Font size="18.0" />
</font>
</Label>
<TextField fx:id="txfFName" editable="false" layoutX="145.0"
layoutY="68.0" prefWidth="190.0" />
<Label focusTraversable="false" layoutX="345.0" layoutY="70.0"
text="Last Name">
<font>
<Font size="18.0" />
</font>
</Label>
<TextField fx:id="txfLName" editable="false" layoutX="440.0"
layoutY="68.0" prefHeight="28.0" prefWidth="230.0" />
<Label focusTraversable="false" layoutX="50.0" layoutY="120.0"
text="Hospital Number">
<font>
<Font size="18.0" />
</font>
</Label>
<TextField fx:id="txfHospNum" alignment="CENTER" editable="false"
layoutX="195.0" layoutY="118.0" prefHeight="28.0" prefWidth="100.0"
text="###-###" />
<Label focusTraversable="false" layoutX="315.0" layoutY="121.0"
text="Room Number">
<font>
<Font size="18.0" />
</font>
</Label>
<TextField fx:id="txfRoomNum" editable="false" layoutX="440.0"
layoutY="118.0" prefHeight="28.0" prefWidth="55.0" text="###" />
</children>
</Pane>
<TableView fx:id="table" editable="true" focusTraversable="false"
layoutX="50.0" layoutY="250.0" prefHeight="200.0" prefWidth="658.0">
<columns>
<TableColumn fx:id="hospitalNumCol" editable="false"
maxWidth="150.0" minWidth="150.0" prefWidth="150.0" resizable="false"
sortable="false" text="Hospital Number" />
<TableColumn fx:id="firstNameCol" editable="false"
maxWidth="200.0" minWidth="200.0" prefWidth="200.0" resizable="false"
sortable="false" text="First Name" />
<TableColumn fx:id="lastNameCol" maxWidth="240.0"
minWidth="240.0" prefWidth="240.0" resizable="false" text="Last Name" />
<TableColumn fx:id="roomNumCol" editable="false"
maxWidth="60.0" minWidth="60.0" prefWidth="60.0" resizable="false"
sortable="false" text="Room" />
</columns>
</TableView>
</children>
</AnchorPane>