Działa dodawanie książek, praca nad dodawaniem reszty

This commit is contained in:
Agnieszka Janicka 2016-06-06 14:41:34 +02:00
parent ab0325b065
commit f7ae927511
32 changed files with 299 additions and 255 deletions

Binary file not shown.

Binary file not shown.

View File

@ -127,9 +127,6 @@
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/> <Font name="Tahoma" size="14" style="0"/>
</Property> </Property>
<Property name="inputVerifier" type="javax.swing.InputVerifier" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new library.Validation(&quot;[a-zA-z0-9]+&quot;, this.add)" type="code"/>
</Property>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bookTitleActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bookTitleActionPerformed"/>
@ -215,6 +212,9 @@
<Font name="Tahoma" size="14" style="0"/> <Font name="Tahoma" size="14" style="0"/>
</Property> </Property>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ISBNActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lcategory"> <Component class="javax.swing.JLabel" name="lcategory">
<Properties> <Properties>

Binary file not shown.

Binary file not shown.

View File

@ -21,7 +21,7 @@ public class Album extends Item {
} }
@Override @Override
public void insertToDB(){ public void insertToDB(){
String query = "INSERT INTO albums VALUES(NULL, '" +this.getName() + "', '" + this.getMusican() + "', '" + this.getYear() + "', '"+ this.getCategory() + "');"; // String query = "INSERT INTO albums VALUES(NULL, '" +this.getName() + "', '" + this.getMusican() + "', '" + this.getYear() + "', '"+ this.getCategory() + "');";
}; };
@Override @Override
public void delFromDB(){ public void delFromDB(){

View File

@ -21,12 +21,14 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initComponents(); initComponents();
} }
public AlbumFieldPattern(boolean required) { public AlbumFieldPattern(boolean required) {
initComponents(); initComponents();
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
albumTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", required)); albumTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", required));
} }
public boolean add = false, delete = false, edit = false; public boolean add = false, delete = false, edit = false;
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
@ -159,11 +161,9 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
private void SaveChangesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveChangesActionPerformed private void SaveChangesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveChangesActionPerformed
if (this.add) { if (this.add) {
JOptionPane.showMessageDialog(null, "DODAJ"); JOptionPane.showMessageDialog(null, "DODAJ");
} } else if (this.edit) {
else if(this.edit){
JOptionPane.showMessageDialog(null, "EDYTUJ"); JOptionPane.showMessageDialog(null, "EDYTUJ");
} } else if (this.delete) {
else if(this.delete){
JOptionPane.showMessageDialog(null, "USUŃ"); JOptionPane.showMessageDialog(null, "USUŃ");
} }
dispose(); dispose();
@ -210,8 +210,6 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
} }
}); });
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables

View File

@ -10,9 +10,11 @@ package library;
* @author Agnieszka * @author Agnieszka
*/ */
public class Book extends Item { public class Book extends Item {
Book() { Book() {
//nothing to do //nothing to do
} }
Book(int id, String n, String an, String asn, int y, String isbn, String p, String c) { Book(int id, String n, String an, String asn, int y, String isbn, String p, String c) {
this.setId(id); this.setId(id);
this.setName(n); this.setName(n);
@ -27,15 +29,21 @@ public class Book extends Item{
@Override @Override
public void insertToDB() { public void insertToDB() {
db.insertBookQ(this); db.insertBookQ(this);
}; }
;
@Override @Override
public void delFromDB() { public void delFromDB() {
String query = "DELETE FROM books WHERE id=" + this.getId() + ";"; String query = "DELETE FROM books WHERE id=" + this.getId() + ";";
}; }
;
@Override @Override
public void editInDB() { public void editInDB() {
}; }
;
/*public void insertQuery(){ /*public void insertQuery(){
System.out.println("INSERT INTO books VALUES('NULL', '" +name + "', '" + authorName + "', '" + authorSurname + "', '"+ publishing + "', '"+ year + "', '"+ ISBN + "', '"+ category + "');"); System.out.println("INSERT INTO books VALUES('NULL', '" +name + "', '" + authorName + "', '" + authorSurname + "', '"+ publishing + "', '"+ year + "', '"+ ISBN + "', '"+ category + "');");
}*/ }*/
@ -43,26 +51,33 @@ public void editInDB(){
public void setPublishing(String s) { public void setPublishing(String s) {
this.publishing = s; this.publishing = s;
} }
public void setAuthorName(String s) { public void setAuthorName(String s) {
this.authorName = s; this.authorName = s;
} }
public void setAuthorSurname(String s) { public void setAuthorSurname(String s) {
this.authorSurname = s; this.authorSurname = s;
} }
public void setISBN(String s) { public void setISBN(String s) {
this.ISBN = s; this.ISBN = s;
} }
public String getAuthorName() { public String getAuthorName() {
return this.authorName; return this.authorName;
} }
public String getAuthorSurname() { public String getAuthorSurname() {
return this.authorSurname; return this.authorSurname;
} }
public String getPublishing() { public String getPublishing() {
return this.publishing; return this.publishing;
} }
public String getISBN() { public String getISBN() {
return this.publishing; return this.ISBN;
} }
private String authorName, authorSurname, publishing, ISBN; private String authorName, authorSurname, publishing, ISBN;
private Database db = new Database(); private Database db = new Database();

View File

@ -127,9 +127,6 @@
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/> <Font name="Tahoma" size="14" style="0"/>
</Property> </Property>
<Property name="inputVerifier" type="javax.swing.InputVerifier" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new library.Validation(&quot;[a-zA-z0-9]+&quot;, this.add)" type="code"/>
</Property>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bookTitleActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bookTitleActionPerformed"/>
@ -215,6 +212,9 @@
<Font name="Tahoma" size="14" style="0"/> <Font name="Tahoma" size="14" style="0"/>
</Property> </Property>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ISBNActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lcategory"> <Component class="javax.swing.JLabel" name="lcategory">
<Properties> <Properties>

View File

@ -5,7 +5,10 @@
*/ */
package library; package library;
import java.sql.SQLException;
import java.util.Arrays; import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -22,14 +25,15 @@ public class BookFieldPattern extends javax.swing.JFrame {
initComponents(); initComponents();
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
} }
public BookFieldPattern(boolean required) { public BookFieldPattern(boolean required) {
initComponents(); initComponents();
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
bookTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", required)); //bookTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", required));
} }
public boolean add = false, delete = false, edit = false; public boolean add = false, delete = false, edit = false;
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
@ -62,7 +66,6 @@ public class BookFieldPattern extends javax.swing.JFrame {
Title.setText("Tytuł:"); Title.setText("Tytuł:");
bookTitle.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N bookTitle.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
bookTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", this.add));
bookTitle.addActionListener(new java.awt.event.ActionListener() { bookTitle.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
bookTitleActionPerformed(evt); bookTitleActionPerformed(evt);
@ -98,6 +101,11 @@ public class BookFieldPattern extends javax.swing.JFrame {
lISBN.setText("ISBN:"); lISBN.setText("ISBN:");
ISBN.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N ISBN.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
ISBN.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ISBNActionPerformed(evt);
}
});
lcategory.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N lcategory.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
lcategory.setText("Kategoria:"); lcategory.setText("Kategoria:");
@ -210,22 +218,13 @@ public class BookFieldPattern extends javax.swing.JFrame {
private void SaveChangesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveChangesActionPerformed private void SaveChangesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveChangesActionPerformed
if (this.add) { if (this.add) {
Book b = new Book();
/* Book b = new Book(0, bookTitle.getText(), authorName.getText(), authorSurname.getText(), Integer.parseInt(year.getText()), ISBN.getText(), publishing.getText(), Category.getSelectedItem().toString());
b.name = bookTitle.getText(); b.insertToDB();
b.authorName = authorName.getText();
b.authorSurname = authorSurname.getText(); } else if (this.edit) {
b.publishing = publishing.getText();
b.year = Integer.parseInt(year.getText());
b.ISBN = ISBN.getText();
b.category = Category.getSelectedItem().toString();
b.insertQuery();
*/
}
else if(this.edit){
JOptionPane.showMessageDialog(null, "EDYTUJ"); JOptionPane.showMessageDialog(null, "EDYTUJ");
} } else if (this.delete) {
else if(this.delete){
JOptionPane.showMessageDialog(null, "USUŃ"); JOptionPane.showMessageDialog(null, "USUŃ");
} }
dispose(); dispose();
@ -239,6 +238,10 @@ public class BookFieldPattern extends javax.swing.JFrame {
// TODO add your handling code here: // TODO add your handling code here:
}//GEN-LAST:event_bookTitleActionPerformed }//GEN-LAST:event_bookTitleActionPerformed
private void ISBNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ISBNActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_ISBNActionPerformed
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
@ -274,8 +277,6 @@ public class BookFieldPattern extends javax.swing.JFrame {
} }
}); });
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables

View File

@ -4,6 +4,7 @@
* and open the template in the editor. * and open the template in the editor.
*/ */
package library; package library;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -13,10 +14,10 @@ import java.sql.Statement;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
/** /**
* *
* @author Agnieszka * @author Agnieszka insert, delete i update do przeniesienia tutaj (9metod)
* insert, delete i update do przeniesienia tutaj (9metod)
*/ */
public class Database { public class Database {
@ -45,8 +46,21 @@ public class Database {
createTables(); createTables();
} }
public void selectAllFromBooks() {
try {
ResultSet result = stat.executeQuery("SELECT * FROM books");
while (result.next()) {
System.out.println("WYniki");
System.out.println(result.getInt("id") + " " + result.getInt("year") + result.getString("name") + result.getString("author_name") + result.getString("author_surname") + result.getString("publishing") + result.getString("isbn") + result.getString("category"));
}
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Błąd przy odczycie z bazy.", "Error:", JOptionPane.INFORMATION_MESSAGE);
}
}
public boolean createTables() { public boolean createTables() {
String createBooks = "CREATE TABLE IF NOT EXISTS books (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(255), author_name varchar(50), author_surname varchar(50), publishing varchar(50), year int, isbn varchar(12), category varchar(100))"; String createBooks = "CREATE TABLE IF NOT EXISTS books (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(255), author_name varchar(50), author_surname varchar(50), publishing varchar(50), year int, isbn varchar(20), category varchar(100))";
String createAlbums = "CREATE TABLE IF NOT EXISTS albums (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(255), musican varchar(50), author_surname varchar(50), year int, category varchar(100))"; String createAlbums = "CREATE TABLE IF NOT EXISTS albums (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(255), musican varchar(50), author_surname varchar(50), year int, category varchar(100))";
String createMovies = "CREATE TABLE IF NOT EXISTS movies (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(255), director varchar(50), year int, category varchar(100))"; String createMovies = "CREATE TABLE IF NOT EXISTS movies (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(255), director varchar(50), year int, category varchar(100))";
try { try {
@ -54,7 +68,7 @@ public class Database {
stat.execute(createAlbums); stat.execute(createAlbums);
stat.execute(createMovies); stat.execute(createMovies);
} catch (SQLException e) { } catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Błąd przy tworzeniu tabel bazy danych.", "Error:", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "Błąd przy odczycie zbazy danych.", "Error:", JOptionPane.INFORMATION_MESSAGE);
return false; return false;
} }
return true; return true;
@ -93,6 +107,22 @@ public class Database {
} }
public void insertAlbumQ(Album a) {
try {
PreparedStatement prepStmt = conn.prepareStatement(
"INSERT INTO albums VALUES (NULL, ?, ?, ?, ?);");
prepStmt.setString(1, a.getName());
prepStmt.setString(2, a.getMusican());
prepStmt.setInt(3, a.getYear());
prepStmt.setString(4, a.getCategory());
prepStmt.execute();
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Błąd przy dodawaniu do bazy", "Error:", JOptionPane.INFORMATION_MESSAGE);
}
}
public List<Book> selectBooks() { public List<Book> selectBooks() {
List<Book> books = new LinkedList<Book>(); List<Book> books = new LinkedList<Book>();
try { try {
@ -108,7 +138,6 @@ public class Database {
publishing = result.getString("publishing"); publishing = result.getString("publishing");
isbn = result.getString("isbn"); isbn = result.getString("isbn");
category = result.getString("category"); category = result.getString("category");
books.add(new Book(id, name, authorName, authorSurname, year, isbn, publishing, category)); books.add(new Book(id, name, authorName, authorSurname, year, isbn, publishing, category));
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -151,6 +180,7 @@ public class Database {
director = result.getString("director"); director = result.getString("director");
category = result.getString("category"); category = result.getString("category");
movies.add(new Movie(id, name, director, year, category)); movies.add(new Movie(id, name, director, year, category));
} }
} catch (SQLException e) { } catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Błąd przy odczycie z bazy.", "Error:", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "Błąd przy odczycie z bazy.", "Error:", JOptionPane.INFORMATION_MESSAGE);
@ -167,4 +197,3 @@ public class Database {
} }
} }
} }

View File

@ -8,37 +8,44 @@ package library;
/** /**
* *
* @author Agnieszka * @author Agnieszka
*
*/ */
public abstract class Item { public abstract class Item {
public abstract void insertToDB(); public abstract void insertToDB();
public abstract void delFromDB(); public abstract void delFromDB();
public abstract void editInDB(); public abstract void editInDB();
public void setName(String s) { public void setName(String s) {
this.name = s; this.name = s;
} }
public void setCategory(String s) { public void setCategory(String s) {
this.category = s; this.category = s;
} }
public void setYear(int i) { public void setYear(int i) {
this.year = i; this.year = i;
} }
public void setId(int i) { public void setId(int i) {
this.id = i; this.id = i;
} }
public String getName() { public String getName() {
return this.name; return this.name;
} }
public String getCategory() { public String getCategory() {
return this.category; return this.category;
} }
public int getYear() { public int getYear() {
return this.year; return this.year;
} }
public int getId() { public int getId() {
return this.id; return this.id;
} }

View File

@ -93,8 +93,6 @@ public class ListResult extends javax.swing.JFrame {
} }
}); });
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables

View File

@ -286,8 +286,11 @@ public class MainMenu extends javax.swing.JFrame {
List<Book> books = new LinkedList<>(); List<Book> books = new LinkedList<>();
books = d.selectBooks(); books = d.selectBooks();
System.out.println("Lista książek:"); System.out.println("Lista książek:");
for(Book k: books) for (Book k : books) {
System.out.println(k); System.out.println(k);
}
d.selectAllFromBooks();
}//GEN-LAST:event_allBooksShowActionPerformed }//GEN-LAST:event_allBooksShowActionPerformed
/** /**

View File

@ -21,12 +21,14 @@ public class MovieFieldPattern extends javax.swing.JFrame {
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initComponents(); initComponents();
} }
public MovieFieldPattern(boolean required) { public MovieFieldPattern(boolean required) {
initComponents(); initComponents();
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
movieTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", required)); movieTitle.setInputVerifier(new library.Validation("[a-zA-z0-9]+", required));
} }
public boolean add = false, delete = false, edit = false; public boolean add = false, delete = false, edit = false;
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
@ -176,11 +178,9 @@ public class MovieFieldPattern extends javax.swing.JFrame {
private void SaveChangesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveChangesActionPerformed private void SaveChangesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveChangesActionPerformed
if (this.add) { if (this.add) {
JOptionPane.showMessageDialog(null, "DODAJ"); JOptionPane.showMessageDialog(null, "DODAJ");
} } else if (this.edit) {
else if(this.edit){
JOptionPane.showMessageDialog(null, "EDYTUJ"); JOptionPane.showMessageDialog(null, "EDYTUJ");
} } else if (this.delete) {
else if(this.delete){
JOptionPane.showMessageDialog(null, "USUŃ"); JOptionPane.showMessageDialog(null, "USUŃ");
} }
dispose(); dispose();
@ -229,8 +229,6 @@ public class MovieFieldPattern extends javax.swing.JFrame {
} }
}); });
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables

View File

@ -14,15 +14,16 @@ import javax.swing.JTextField;
/** /**
* *
* @author Agnieszka * @author Agnieszka walitator używający wyrażeń regularnych do sprawdzania pól
* walitator używający wyrażeń regularnych do sprawdzania pól formularzy * formularzy wyrażenia regularne jako parametr konstuktora
* wyrażenia regularne jako parametr konstuktora
*/ */
public class Validation extends InputVerifier { public class Validation extends InputVerifier {
public Validation(String ex, boolean rq) { public Validation(String ex, boolean rq) {
expression = ex; expression = ex;
required = rq; required = rq;
} }
@Override @Override
public boolean verify(JComponent input) { public boolean verify(JComponent input) {
JTextField tf = (JTextField) input; JTextField tf = (JTextField) input;
@ -31,27 +32,21 @@ public class Validation extends InputVerifier {
if (required) { if (required) {
if (m.matches()) { if (m.matches()) {
return true; return true;
} } else {
else{
if ("".equals(tf.getText())) { if ("".equals(tf.getText())) {
JOptionPane.showMessageDialog(null, "Pole wymagane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "Pole wymagane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE);
} } else {
else{
JOptionPane.showMessageDialog(null, "Niepoprawne dane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "Niepoprawne dane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE);
} }
return false; return false;
} }
} } else if (m.matches() || "".equals(tf.getText())) {
else{
if (m.matches() || "".equals(tf.getText())){
return true; return true;
} } else {
else{
JOptionPane.showMessageDialog(null, "Niepoprawne dane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "Niepoprawne dane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE);
return false; return false;
} }
} }
}
String expression; String expression;
boolean required = false; boolean required = false;
} }