Select Git revision
HelloController.java 15.66 KiB
package com.example.tpfx;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class HelloController {
static ArrayList<Contact> contactArray = new ArrayList<>();
int selectedID = 0; //Save the id of the selected item in the list view
boolean imported = false; //Used to know whenever we should enable or disable button save/edit
ObservableList<String> ctType = FXCollections.observableArrayList("Friend", "Family", "Professional");
//Fx fields
@FXML
private TextField txtFirst;
@FXML
private TextField txtSearch;
@FXML
private TextField txtLast;
@FXML
private TextField txtAdd;
@FXML
private TextField txtPhone;
@FXML
private TextField txtEmail;
@FXML
private TextField txtSocial;
@FXML
private TextField txtJob;
@FXML
private TextField txtOther;
@FXML
private Label lblOther;
@FXML
private Button btnAdd;
@FXML
private Button btnDelete;
@FXML
private Button btnEdit;
@FXML
private ListView LstCt;
@FXML
private ComboBox cbxType;
//Fx functions
/**
* Form start up. Hide and Disable unwanted component
*/
@FXML
protected void initialize() {
cbxType.setValue("Friend");
cbxType.setItems(ctType);
lblOther.setVisible(false);
txtOther.setVisible(false);
btnEdit.setDisable(true);
btnDelete.setDisable(true);
btnAdd.setDisable(true);
}
/**
* Redirect the addition of a contact to the correct methode
*/
@FXML
protected void AddCt() {
//enhanced switch, doesn't need break
switch (cbxType.getValue().toString()){ //Use the combo box value