diff --git a/src/library/BookFieldPattern.form b/src/library/BookFieldPattern.form
index ebdd0e5..cdaa58b 100644
--- a/src/library/BookFieldPattern.form
+++ b/src/library/BookFieldPattern.form
@@ -142,6 +142,7 @@
+
diff --git a/src/library/BookFieldPattern.java b/src/library/BookFieldPattern.java
index 6aa0c1f..32a3e08 100644
--- a/src/library/BookFieldPattern.java
+++ b/src/library/BookFieldPattern.java
@@ -32,7 +32,12 @@ public class BookFieldPattern extends javax.swing.JFrame {
public BookFieldPattern(boolean required) {
initComponents();
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- //bookTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", required));
+ bookTitle.setInputVerifier(verify);
+ authorName.setInputVerifier(verify);
+ authorSurname.setInputVerifier(verify);
+ year.setInputVerifier(verify);
+ ISBN.setInputVerifier(verify);
+ publishing.setInputVerifier(verify);
}
public boolean add = false, delete = false, edit = false, search = false;
@@ -344,7 +349,7 @@ public class BookFieldPattern extends javax.swing.JFrame {
private javax.swing.JTextField authorSurname;
private javax.swing.JLabel authorname;
private javax.swing.JLabel authorsurname;
- private javax.swing.JTextField bookTitle;
+ javax.swing.JTextField bookTitle;
private javax.swing.JButton cancel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel lISBN;
diff --git a/src/library/Validation.java b/src/library/Validation.java
index 97e7807..a072729 100644
--- a/src/library/Validation.java
+++ b/src/library/Validation.java
@@ -31,39 +31,40 @@ public class Validation extends InputVerifier {
public boolean checkField(JComponent input) {
JTextField tf = (JTextField) input;
- if(required){
- if("".equals(tf.getText())){
+ if (required) {
+ if ((tf.getText().equals(""))) {
JOptionPane.showMessageDialog(null, "Pole wymagane!", "Błąd wprowadzanych danych", JOptionPane.INFORMATION_MESSAGE);
- return false;
+ return false;
}
}
- if (input.getName().equals("year")) {
-
- if (!"".equals(tf.getText())) {
- try {
- year = Integer.parseInt(tf.getText());
- if (year > 2016 || year < 1900) {
- JOptionPane.showMessageDialog(null, "Data spoza zakresu.", "Błąd wprowadzanych danych", JOptionPane.INFORMATION_MESSAGE);
+ if (input.getName() != null){
+ if (input.getName().equals("year")) {
+ if (!"".equals(tf.getText())) {
+ try {
+ year = Integer.parseInt(tf.getText());
+ if (year > 2016 || year < 1900) {
+ JOptionPane.showMessageDialog(null, "Data spoza zakresu.", "Błąd wprowadzanych danych", JOptionPane.INFORMATION_MESSAGE);
+ return false;
+ }
+ } catch (NumberFormatException e) {
+ JOptionPane.showMessageDialog(null, "Wpisz datę w formacie: YYYY", "Błąd wprowadzanych danych", JOptionPane.INFORMATION_MESSAGE);
return false;
}
- } catch (NumberFormatException e) {
- JOptionPane.showMessageDialog(null, "Wpisz datę w formacie: YYYY", "Błąd wprowadzanych danych", JOptionPane.INFORMATION_MESSAGE);
- return false;
}
}
- }
- if (input.getName().equals("isbn")) {
- if (!"".equals(tf.getText())) {
- Pattern p = Pattern.compile("[0-9][0-9][0-9]-[0-9]-[0-9][0-9][0-9][0-9]-[0-9]");
- Matcher m = p.matcher(tf.getText());
- if (m.matches()) {
- return true;
- } else {
- JOptionPane.showMessageDialog(null, "Niepoprawne dane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE);
- return false;
+ if (input.getName().equals("isbn")) {
+ if (!"".equals(tf.getText())) {
+ Pattern p = Pattern.compile("[0-9][0-9][0-9]-[0-9]-[0-9][0-9][0-9][0-9]-[0-9]");
+ Matcher m = p.matcher(tf.getText());
+ if (m.matches()) {
+ return true;
+ } else {
+ JOptionPane.showMessageDialog(null, "Niepoprawne dane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE);
+ return false;
+ }
}
+ return true;
}
- return true;
}
return true;