├── .classpath
├── .project
├── README.md
├── bin
├── TestDatabase.class
├── controller
│ └── Controller.class
├── gui
│ ├── AgeCategory.class
│ ├── App$1.class
│ ├── App.class
│ ├── EmploymentCategoryEditor$1.class
│ ├── EmploymentCategoryEditor.class
│ ├── EmploymentCategoryRenderer.class
│ ├── FormEvent.class
│ ├── FormListener.class
│ ├── FormPanel$1.class
│ ├── FormPanel$2.class
│ ├── FormPanel.class
│ ├── IconRenderer.class
│ ├── MainFrame$1.class
│ ├── MainFrame$10.class
│ ├── MainFrame$11.class
│ ├── MainFrame$12.class
│ ├── MainFrame$13.class
│ ├── MainFrame$14.class
│ ├── MainFrame$15.class
│ ├── MainFrame$2.class
│ ├── MainFrame$3.class
│ ├── MainFrame$4.class
│ ├── MainFrame$5.class
│ ├── MainFrame$6.class
│ ├── MainFrame$7.class
│ ├── MainFrame$8.class
│ ├── MainFrame$9.class
│ ├── MainFrame.class
│ ├── PersonFileFilter.class
│ ├── PersonTableListener.class
│ ├── PersonTableModel.class
│ ├── TablePanel$1.class
│ ├── TablePanel$2.class
│ ├── TablePanel$3.class
│ ├── TablePanel.class
│ ├── TextPanel.class
│ ├── TextPanel2$1.class
│ ├── TextPanel2.class
│ ├── Toolbar.class
│ ├── ToolbarListener.class
│ └── Utils.class
├── images
│ ├── 1400444437_save_accept.png
│ ├── 1400444440_Save.png
│ ├── 1400444542_save_16.png
│ ├── 1400444547_document-save.png
│ ├── 1400444559_view-refresh.png
│ ├── 1400444563_Synchronize.png
│ ├── 1400444569_gtk-refresh.png
│ ├── 1400444586_import.png
│ ├── 1400444602_table-export.png
│ ├── 1400444918_application_view_xp_terminal.png
│ ├── 1400445120_Error.png
│ ├── 1400445243_text_horizontalrule.png
│ ├── 1400445397_accept.png
│ ├── 1400445557_Windows_16x16.png
│ ├── 1400445676_Help.png
│ ├── 1400446085_Table_16x16.png
│ ├── 1400447294_1.png
│ ├── 1400462129_cart_add.png
│ ├── 1400956144_gear__plus.png
│ ├── Refresh16.gif
│ ├── Save16.gif
│ ├── Server16.gif
│ ├── car.png
│ ├── gear.png
│ ├── import1.png
│ ├── notepad.gif
│ ├── price.png
│ └── ware.png
└── model
│ ├── AgeCategory.class
│ ├── Database.class
│ ├── EmploymentCategory.class
│ ├── Gender.class
│ └── Person.class
└── src
├── TestDatabase.java
├── controller
└── Controller.java
├── gui
├── App.java
├── EmploymentCategoryEditor.java
├── EmploymentCategoryRenderer.java
├── FormEvent.java
├── FormListener.java
├── FormPanel.java
├── IconRenderer.java
├── MainFrame.java
├── PersonFileFilter.java
├── PersonTableListener.java
├── PersonTableModel.java
├── TablePanel.java
├── TextPanel.java
├── TextPanel2.java
├── Toolbar.java
├── ToolbarListener.java
└── Utils.java
├── images
├── 1400444437_save_accept.png
├── 1400444440_Save.png
├── 1400444542_save_16.png
├── 1400444547_document-save.png
├── 1400444559_view-refresh.png
├── 1400444563_Synchronize.png
├── 1400444569_gtk-refresh.png
├── 1400444586_import.png
├── 1400444602_table-export.png
├── 1400444918_application_view_xp_terminal.png
├── 1400445120_Error.png
├── 1400445243_text_horizontalrule.png
├── 1400445397_accept.png
├── 1400445557_Windows_16x16.png
├── 1400445676_Help.png
├── 1400446085_Table_16x16.png
├── 1400447294_1.png
├── 1400462129_cart_add.png
├── 1400956144_gear__plus.png
├── Refresh16.gif
├── Save16.gif
├── Server16.gif
├── car.png
├── gear.png
├── import1.png
├── notepad.gif
├── price.png
└── ware.png
└── model
├── AgeCategory.java
├── Database.java
├── EmploymentCategory.java
├── Gender.java
└── Person.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Swing26 - Tables
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Java CRUD App
2 | Simple java business application with CRUD functional made for university course.
3 |
4 | ## `Note!`As the project become much visible so I strongly encourage everyone to use the provided code at your own risk. It is very dirty and hacky!
5 |
6 | To run it you need to have
7 | - Eclipse IDE (J2EE) **preferred**
8 |
9 | *or you need to install `JDK` on your own.*
10 | - MySQL pre-installed
11 | - some MySQL UI ( I used MySql Workbench )
12 | - mysql-connector
13 |
14 | also I used `weblaf` since it has better look and feel.
15 |
--------------------------------------------------------------------------------
/bin/TestDatabase.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/TestDatabase.class
--------------------------------------------------------------------------------
/bin/controller/Controller.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/controller/Controller.class
--------------------------------------------------------------------------------
/bin/gui/AgeCategory.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/AgeCategory.class
--------------------------------------------------------------------------------
/bin/gui/App$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/App$1.class
--------------------------------------------------------------------------------
/bin/gui/App.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/App.class
--------------------------------------------------------------------------------
/bin/gui/EmploymentCategoryEditor$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/EmploymentCategoryEditor$1.class
--------------------------------------------------------------------------------
/bin/gui/EmploymentCategoryEditor.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/EmploymentCategoryEditor.class
--------------------------------------------------------------------------------
/bin/gui/EmploymentCategoryRenderer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/EmploymentCategoryRenderer.class
--------------------------------------------------------------------------------
/bin/gui/FormEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/FormEvent.class
--------------------------------------------------------------------------------
/bin/gui/FormListener.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/FormListener.class
--------------------------------------------------------------------------------
/bin/gui/FormPanel$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/FormPanel$1.class
--------------------------------------------------------------------------------
/bin/gui/FormPanel$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/FormPanel$2.class
--------------------------------------------------------------------------------
/bin/gui/FormPanel.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/FormPanel.class
--------------------------------------------------------------------------------
/bin/gui/IconRenderer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/IconRenderer.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$1.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$10.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$10.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$11.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$11.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$12.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$12.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$13.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$13.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$14.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$14.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$15.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$15.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$2.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$3.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$4.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$4.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$5.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$5.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$6.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$6.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$7.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$7.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$8.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$8.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame$9.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame$9.class
--------------------------------------------------------------------------------
/bin/gui/MainFrame.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/MainFrame.class
--------------------------------------------------------------------------------
/bin/gui/PersonFileFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/PersonFileFilter.class
--------------------------------------------------------------------------------
/bin/gui/PersonTableListener.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/PersonTableListener.class
--------------------------------------------------------------------------------
/bin/gui/PersonTableModel.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/PersonTableModel.class
--------------------------------------------------------------------------------
/bin/gui/TablePanel$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/TablePanel$1.class
--------------------------------------------------------------------------------
/bin/gui/TablePanel$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/TablePanel$2.class
--------------------------------------------------------------------------------
/bin/gui/TablePanel$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/TablePanel$3.class
--------------------------------------------------------------------------------
/bin/gui/TablePanel.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/TablePanel.class
--------------------------------------------------------------------------------
/bin/gui/TextPanel.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/TextPanel.class
--------------------------------------------------------------------------------
/bin/gui/TextPanel2$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/TextPanel2$1.class
--------------------------------------------------------------------------------
/bin/gui/TextPanel2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/TextPanel2.class
--------------------------------------------------------------------------------
/bin/gui/Toolbar.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/Toolbar.class
--------------------------------------------------------------------------------
/bin/gui/ToolbarListener.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/ToolbarListener.class
--------------------------------------------------------------------------------
/bin/gui/Utils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/gui/Utils.class
--------------------------------------------------------------------------------
/bin/images/1400444437_save_accept.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400444437_save_accept.png
--------------------------------------------------------------------------------
/bin/images/1400444440_Save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400444440_Save.png
--------------------------------------------------------------------------------
/bin/images/1400444542_save_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400444542_save_16.png
--------------------------------------------------------------------------------
/bin/images/1400444547_document-save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400444547_document-save.png
--------------------------------------------------------------------------------
/bin/images/1400444559_view-refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400444559_view-refresh.png
--------------------------------------------------------------------------------
/bin/images/1400444563_Synchronize.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400444563_Synchronize.png
--------------------------------------------------------------------------------
/bin/images/1400444569_gtk-refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400444569_gtk-refresh.png
--------------------------------------------------------------------------------
/bin/images/1400444586_import.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400444586_import.png
--------------------------------------------------------------------------------
/bin/images/1400444602_table-export.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400444602_table-export.png
--------------------------------------------------------------------------------
/bin/images/1400444918_application_view_xp_terminal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400444918_application_view_xp_terminal.png
--------------------------------------------------------------------------------
/bin/images/1400445120_Error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400445120_Error.png
--------------------------------------------------------------------------------
/bin/images/1400445243_text_horizontalrule.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400445243_text_horizontalrule.png
--------------------------------------------------------------------------------
/bin/images/1400445397_accept.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400445397_accept.png
--------------------------------------------------------------------------------
/bin/images/1400445557_Windows_16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400445557_Windows_16x16.png
--------------------------------------------------------------------------------
/bin/images/1400445676_Help.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400445676_Help.png
--------------------------------------------------------------------------------
/bin/images/1400446085_Table_16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400446085_Table_16x16.png
--------------------------------------------------------------------------------
/bin/images/1400447294_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400447294_1.png
--------------------------------------------------------------------------------
/bin/images/1400462129_cart_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400462129_cart_add.png
--------------------------------------------------------------------------------
/bin/images/1400956144_gear__plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/1400956144_gear__plus.png
--------------------------------------------------------------------------------
/bin/images/Refresh16.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/Refresh16.gif
--------------------------------------------------------------------------------
/bin/images/Save16.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/Save16.gif
--------------------------------------------------------------------------------
/bin/images/Server16.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/Server16.gif
--------------------------------------------------------------------------------
/bin/images/car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/car.png
--------------------------------------------------------------------------------
/bin/images/gear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/gear.png
--------------------------------------------------------------------------------
/bin/images/import1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/import1.png
--------------------------------------------------------------------------------
/bin/images/notepad.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/notepad.gif
--------------------------------------------------------------------------------
/bin/images/price.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/price.png
--------------------------------------------------------------------------------
/bin/images/ware.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/images/ware.png
--------------------------------------------------------------------------------
/bin/model/AgeCategory.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/model/AgeCategory.class
--------------------------------------------------------------------------------
/bin/model/Database.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/model/Database.class
--------------------------------------------------------------------------------
/bin/model/EmploymentCategory.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/model/EmploymentCategory.class
--------------------------------------------------------------------------------
/bin/model/Gender.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/model/Gender.class
--------------------------------------------------------------------------------
/bin/model/Person.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/bin/model/Person.class
--------------------------------------------------------------------------------
/src/TestDatabase.java:
--------------------------------------------------------------------------------
1 | import java.sql.SQLException;
2 |
3 | import model.AgeCategory;
4 | import model.Database;
5 | import model.EmploymentCategory;
6 | import model.Gender;
7 | import model.Person;
8 |
9 |
10 | public class TestDatabase {
11 |
12 | public static void main(String[] args)
13 | {
14 |
15 |
16 | System.out.println("Running database test");
17 |
18 | Database db = new Database();
19 | try {
20 | db.connect();
21 | } catch (Exception e) {
22 | // TODO Auto-generated catch block
23 | e.printStackTrace();
24 | }
25 |
26 | db.addPerson(new Person("Joe222","sdsdsdsd",AgeCategory.Nissan,EmploymentCategory.sklad,"2323",false,Gender.no));
27 | db.addPerson(new Person("Joe222","sdsdsdsd",AgeCategory.Nissan,EmploymentCategory.sklad,"2323",false,Gender.no));
28 | db.addPerson(new Person("Suzana","sdssdsdsdd",AgeCategory.Nissan,EmploymentCategory.sklad,"43",true,Gender.no));
29 | db.addPerson(new Person("qwqw","sd12dd",AgeCategory.Mazda,EmploymentCategory.no,"43",true,Gender.yes));
30 | db.addPerson(new Person("qwqw","sd12dd",AgeCategory.Mazda,EmploymentCategory.no,"43",true,Gender.yes));
31 | db.addPerson(new Person("qwasasqw","sd12dd",AgeCategory.Mazda,EmploymentCategory.no,"43",true,Gender.yes));
32 |
33 | try {
34 | db.save();
35 | } catch (SQLException e) {
36 | // TODO Auto-generated catch block
37 | e.printStackTrace();
38 | }
39 |
40 | try {
41 | db.load();
42 | } catch (SQLException e) {
43 | // TODO Auto-generated catch block
44 | e.printStackTrace();
45 | }
46 | db.disconnect();
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/controller/Controller.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/controller/Controller.java
--------------------------------------------------------------------------------
/src/gui/App.java:
--------------------------------------------------------------------------------
1 | package gui;
2 | import javax.swing.SwingUtilities;
3 |
4 | public class App {
5 |
6 | public static void main(String[] args) {
7 |
8 | SwingUtilities.invokeLater(new Runnable() {
9 | public void run() {
10 | new MainFrame();
11 | }
12 | });
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/gui/EmploymentCategoryEditor.java:
--------------------------------------------------------------------------------
1 | package gui;
2 |
3 | import java.awt.Component;
4 | import java.awt.event.ActionEvent;
5 | import java.awt.event.ActionListener;
6 | import java.util.EventObject;
7 |
8 | import javax.swing.AbstractCellEditor;
9 | import javax.swing.JComboBox;
10 | import javax.swing.JTable;
11 | import javax.swing.table.TableCellEditor;
12 |
13 | import model.EmploymentCategory;
14 |
15 | public class EmploymentCategoryEditor extends AbstractCellEditor implements TableCellEditor {
16 |
17 | private JComboBox combo;
18 |
19 | public EmploymentCategoryEditor()
20 | {
21 | combo = new JComboBox(EmploymentCategory.values());
22 | }
23 | @Override
24 | public boolean isCellEditable(EventObject e) {
25 |
26 | return true;
27 | }
28 |
29 | @Override
30 | public Object getCellEditorValue() {
31 | // TODO Auto-generated method stub
32 | return combo.getSelectedItem();
33 | }
34 |
35 | @Override
36 | public Component getTableCellEditorComponent(JTable table, Object value,
37 | boolean isSelected, int row, int column) {
38 |
39 |
40 | combo.setSelectedItem(value);
41 |
42 | combo.addActionListener(new ActionListener()
43 | {
44 |
45 | @Override
46 | public void actionPerformed(ActionEvent arg0) {
47 | fireEditingStopped();
48 |
49 | }
50 |
51 | });
52 |
53 |
54 | return combo;
55 | }
56 |
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/gui/EmploymentCategoryRenderer.java:
--------------------------------------------------------------------------------
1 | package gui;
2 |
3 | import java.awt.Component;
4 |
5 | import javax.swing.JComboBox;
6 | import javax.swing.JTable;
7 | import javax.swing.table.TableCellRenderer;
8 |
9 | import model.EmploymentCategory;
10 |
11 | public class EmploymentCategoryRenderer implements TableCellRenderer {
12 |
13 | private JComboBox combo;
14 |
15 | public EmploymentCategoryRenderer() {
16 | combo = new JComboBox(EmploymentCategory.values());
17 | }
18 |
19 | @Override
20 | public Component getTableCellRendererComponent(JTable table, Object value,
21 | boolean isSelected, boolean hasFocus, int row, int column) {
22 |
23 | combo.setSelectedItem(value);
24 | return combo;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/gui/FormEvent.java:
--------------------------------------------------------------------------------
1 | package gui;
2 | import java.awt.event.KeyEvent;
3 | import java.util.EventObject;
4 |
5 | public class FormEvent extends EventObject {
6 |
7 | private String name;
8 | private String occupation;
9 | private int ageCategory;
10 | private String empCat;
11 | private String taxId;
12 | private boolean usCitizen;
13 | private String gender;
14 |
15 | public FormEvent(Object source) {
16 | super(source);
17 | }
18 |
19 | public FormEvent(Object source, String name, String occupation, int ageCat,
20 | String empCat, String taxId, boolean usCitizen, String gender) {
21 | super(source);
22 |
23 | this.name = name;
24 | this.occupation = occupation;
25 | this.ageCategory = ageCat;
26 | this.empCat = empCat;
27 | this.taxId = taxId;
28 | this.usCitizen = usCitizen;
29 | this.gender = gender;
30 | }
31 |
32 | public String getGender() {
33 | return gender;
34 | }
35 |
36 | public String getTaxId() {
37 | return taxId;
38 | }
39 |
40 | public boolean isUsCitizen() {
41 | return usCitizen;
42 | }
43 |
44 | public String getName() {
45 | return name;
46 | }
47 |
48 | public void setName(String name) {
49 | this.name = name;
50 | }
51 |
52 | public String getOccupation() {
53 | return occupation;
54 | }
55 |
56 | public void setOccupation(String occupation) {
57 | this.occupation = occupation;
58 | }
59 |
60 | public int getAgeCategory() {
61 | return ageCategory;
62 | }
63 |
64 | public String getEmploymentCategory() {
65 | return empCat;
66 | }
67 |
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/gui/FormListener.java:
--------------------------------------------------------------------------------
1 | package gui;
2 | import java.util.EventListener;
3 |
4 | public interface FormListener extends EventListener {
5 | public void formEventOccurred(FormEvent e);
6 | }
7 |
--------------------------------------------------------------------------------
/src/gui/FormPanel.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/gui/FormPanel.java
--------------------------------------------------------------------------------
/src/gui/IconRenderer.java:
--------------------------------------------------------------------------------
1 | package gui;
2 |
3 | import java.net.URL;
4 |
5 | import javax.swing.Icon;
6 | import javax.swing.ImageIcon;
7 | import javax.swing.table.DefaultTableCellRenderer;
8 |
9 | public class IconRenderer extends DefaultTableCellRenderer {
10 | public IconRenderer() { super(); }
11 |
12 | public void setValue(String value) {
13 | if (value == null) {
14 | setText("");
15 | }
16 | else
17 | {
18 |
19 | setIcon(createIcon(value));
20 | }
21 | }
22 |
23 |
24 |
25 | private ImageIcon createIcon(String path)
26 | {
27 | URL url = getClass().getResource(path);
28 |
29 | if(url == null)
30 | {
31 | System.err.println("Unabled to load image"+path);
32 | }
33 |
34 | ImageIcon icon = new ImageIcon(url);
35 |
36 | return icon;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/gui/MainFrame.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/gui/MainFrame.java
--------------------------------------------------------------------------------
/src/gui/PersonFileFilter.java:
--------------------------------------------------------------------------------
1 | package gui;
2 | import java.io.File;
3 |
4 | import javax.swing.filechooser.FileFilter;
5 |
6 |
7 | public class PersonFileFilter extends FileFilter {
8 |
9 | @Override
10 | public boolean accept(File file) {
11 |
12 | if(file.isDirectory()) {
13 | return true;
14 | }
15 |
16 | String name = file.getName();
17 |
18 | String extension = Utils.getFileExtension(name);
19 |
20 | if(extension == null) {
21 | return false;
22 | }
23 |
24 | if(extension.equals("per")) {
25 | return true;
26 | }
27 |
28 | return false;
29 | }
30 |
31 | @Override
32 | public String getDescription() {
33 | return "Person database file (*.per)";
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/gui/PersonTableListener.java:
--------------------------------------------------------------------------------
1 | package gui;
2 |
3 | public interface PersonTableListener
4 | {
5 | public void rowDeleted(int row);
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/gui/PersonTableModel.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/gui/PersonTableModel.java
--------------------------------------------------------------------------------
/src/gui/TablePanel.java:
--------------------------------------------------------------------------------
1 | package gui;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.event.ActionEvent;
5 | import java.awt.event.ActionListener;
6 | import java.awt.event.MouseAdapter;
7 | import java.awt.event.MouseEvent;
8 | import java.util.List;
9 |
10 | import javax.swing.ImageIcon;
11 | import javax.swing.JMenuItem;
12 | import javax.swing.JPanel;
13 | import javax.swing.JPopupMenu;
14 | import javax.swing.JScrollPane;
15 | import javax.swing.JTable;
16 |
17 | import model.EmploymentCategory;
18 | import model.Person;
19 |
20 | public class TablePanel extends JPanel {
21 |
22 | private JTable table;
23 | private PersonTableModel tableModel;
24 | private JPopupMenu popup;
25 | private JPopupMenu popup2;
26 | private PersonTableListener personTableListener;
27 |
28 |
29 | public TablePanel() {
30 |
31 | tableModel = new PersonTableModel();
32 | table = new JTable(tableModel);
33 | popup = new JPopupMenu();
34 | popup2 = new JPopupMenu();
35 |
36 | IconRenderer icRen = new IconRenderer();
37 | icRen.setValue("/images/gear.png");
38 |
39 |
40 |
41 | table.setDefaultRenderer(EmploymentCategory.class, new EmploymentCategoryRenderer());
42 | table.setDefaultEditor(EmploymentCategory.class, new EmploymentCategoryEditor());
43 | table.setDefaultRenderer(ImageIcon.class,icRen);
44 |
45 | table.setRowHeight(24);
46 |
47 |
48 |
49 |
50 | JMenuItem removeItem = new JMenuItem("Delete Row");
51 | JMenuItem selectAllItem = new JMenuItem("Select All");
52 | popup.add(removeItem);
53 | popup.add(selectAllItem);
54 |
55 | selectAllItem.addActionListener(new ActionListener() {
56 |
57 |
58 | public void actionPerformed(ActionEvent e) {
59 |
60 | table.selectAll();
61 |
62 | }
63 | });
64 |
65 |
66 | removeItem.addActionListener(new ActionListener()
67 | {
68 | public void actionPerformed(ActionEvent e) {
69 |
70 | int row = table.getSelectedRow();
71 |
72 | if(personTableListener != null)
73 | {
74 | personTableListener.rowDeleted(row);
75 | tableModel.fireTableRowsDeleted(row, row);
76 | }
77 |
78 | }
79 |
80 | });
81 |
82 |
83 | table.addMouseListener(new MouseAdapter()
84 | {
85 | public void mousePressed(MouseEvent e) {
86 |
87 | int row = table.rowAtPoint(e.getPoint());
88 |
89 | table.getSelectionModel().setSelectionInterval(row,row );
90 | if(e.getButton() == MouseEvent.BUTTON3 )
91 | {
92 | popup.show(table, e.getX(), e.getY());
93 |
94 | }
95 |
96 | }
97 |
98 | });
99 |
100 | setLayout(new BorderLayout());
101 |
102 | add(new JScrollPane(table), BorderLayout.CENTER);
103 | }
104 |
105 |
106 | public void setData(List db) {
107 | tableModel.setData(db);
108 | }
109 |
110 | public void refresh() {
111 | tableModel.fireTableDataChanged();
112 | }
113 | public void setPersonTableListener(PersonTableListener listener)
114 | {
115 | this.personTableListener = listener;
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/src/gui/TextPanel.java:
--------------------------------------------------------------------------------
1 | package gui;
2 | import java.awt.BorderLayout;
3 | import java.awt.Dimension;
4 |
5 | import javax.swing.JPanel;
6 | import javax.swing.JScrollPane;
7 | import javax.swing.JTextArea;
8 |
9 |
10 | public class TextPanel extends JPanel {
11 |
12 | private JTextArea textArea;
13 |
14 | public TextPanel() {
15 |
16 | Dimension dim = getPreferredSize();
17 | dim.height = 75;
18 | setPreferredSize(dim);
19 | textArea = new JTextArea();
20 | textArea.enable(false);
21 |
22 |
23 | setLayout(new BorderLayout());
24 |
25 | add(new JScrollPane(textArea), BorderLayout.CENTER);
26 | }
27 |
28 | public void appendText(String text) {
29 | textArea.append(text);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/gui/TextPanel2.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/gui/TextPanel2.java
--------------------------------------------------------------------------------
/src/gui/Toolbar.java:
--------------------------------------------------------------------------------
1 | package gui;
2 | import java.awt.FlowLayout;
3 | import java.awt.event.ActionEvent;
4 | import java.awt.event.ActionListener;
5 | import java.net.URL;
6 |
7 | import javax.swing.BorderFactory;
8 | import javax.swing.Icon;
9 | import javax.swing.ImageIcon;
10 | import javax.swing.JButton;
11 | import javax.swing.JPanel;
12 |
13 |
14 | public class Toolbar extends JPanel implements ActionListener {
15 | private JButton saveButton;
16 | private JButton refreshButton;
17 |
18 | private ToolbarListener textListener;
19 |
20 | public Toolbar() {
21 | setBorder(BorderFactory.createEtchedBorder());
22 |
23 | saveButton = new JButton("Save");
24 | saveButton.setIcon(createIcon("/images/1400444547_document-save.png"));
25 |
26 | refreshButton = new JButton("Refresh");
27 | refreshButton.setIcon(createIcon("/images/1400444569_gtk-refresh.png"));
28 |
29 | saveButton.addActionListener(this);
30 | refreshButton.addActionListener(this);
31 |
32 | setLayout(new FlowLayout(FlowLayout.LEFT));
33 |
34 | add(saveButton);
35 | add(refreshButton);
36 | }
37 |
38 | private ImageIcon createIcon(String path)
39 | {
40 | URL url = getClass().getResource(path);
41 |
42 | if(url == null)
43 | {
44 | System.err.println("Unabled to load image"+path);
45 | }
46 |
47 | ImageIcon icon = new ImageIcon(url);
48 |
49 | return icon;
50 | }
51 |
52 | public void setToolbarListener(ToolbarListener listener) {
53 | this.textListener = listener;
54 | }
55 |
56 | @Override
57 | public void actionPerformed(ActionEvent e) {
58 | JButton clicked = (JButton)e.getSource();
59 |
60 | if(clicked == saveButton) {
61 | if(textListener != null) {
62 | textListener.saveEventOccured();
63 | }
64 | }
65 | else if(clicked == refreshButton) {
66 | if(textListener != null) {
67 | textListener.refreshEventOccured();
68 | }
69 | }
70 |
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/gui/ToolbarListener.java:
--------------------------------------------------------------------------------
1 | package gui;
2 |
3 | public interface ToolbarListener {
4 | public void saveEventOccured();
5 | public void refreshEventOccured();
6 | }
7 |
--------------------------------------------------------------------------------
/src/gui/Utils.java:
--------------------------------------------------------------------------------
1 | package gui;
2 |
3 | public class Utils {
4 |
5 | public static String getFileExtension(String name) {
6 |
7 | int pointIndex = name.lastIndexOf(".");
8 |
9 | if(pointIndex == -1) {
10 | return null;
11 | }
12 |
13 | if(pointIndex == name.length()-1) {
14 | return null;
15 | }
16 |
17 | return name.substring(pointIndex+1, name.length());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/images/1400444437_save_accept.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400444437_save_accept.png
--------------------------------------------------------------------------------
/src/images/1400444440_Save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400444440_Save.png
--------------------------------------------------------------------------------
/src/images/1400444542_save_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400444542_save_16.png
--------------------------------------------------------------------------------
/src/images/1400444547_document-save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400444547_document-save.png
--------------------------------------------------------------------------------
/src/images/1400444559_view-refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400444559_view-refresh.png
--------------------------------------------------------------------------------
/src/images/1400444563_Synchronize.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400444563_Synchronize.png
--------------------------------------------------------------------------------
/src/images/1400444569_gtk-refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400444569_gtk-refresh.png
--------------------------------------------------------------------------------
/src/images/1400444586_import.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400444586_import.png
--------------------------------------------------------------------------------
/src/images/1400444602_table-export.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400444602_table-export.png
--------------------------------------------------------------------------------
/src/images/1400444918_application_view_xp_terminal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400444918_application_view_xp_terminal.png
--------------------------------------------------------------------------------
/src/images/1400445120_Error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400445120_Error.png
--------------------------------------------------------------------------------
/src/images/1400445243_text_horizontalrule.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400445243_text_horizontalrule.png
--------------------------------------------------------------------------------
/src/images/1400445397_accept.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400445397_accept.png
--------------------------------------------------------------------------------
/src/images/1400445557_Windows_16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400445557_Windows_16x16.png
--------------------------------------------------------------------------------
/src/images/1400445676_Help.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400445676_Help.png
--------------------------------------------------------------------------------
/src/images/1400446085_Table_16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400446085_Table_16x16.png
--------------------------------------------------------------------------------
/src/images/1400447294_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400447294_1.png
--------------------------------------------------------------------------------
/src/images/1400462129_cart_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400462129_cart_add.png
--------------------------------------------------------------------------------
/src/images/1400956144_gear__plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/1400956144_gear__plus.png
--------------------------------------------------------------------------------
/src/images/Refresh16.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/Refresh16.gif
--------------------------------------------------------------------------------
/src/images/Save16.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/Save16.gif
--------------------------------------------------------------------------------
/src/images/Server16.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/Server16.gif
--------------------------------------------------------------------------------
/src/images/car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/car.png
--------------------------------------------------------------------------------
/src/images/gear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/gear.png
--------------------------------------------------------------------------------
/src/images/import1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/import1.png
--------------------------------------------------------------------------------
/src/images/notepad.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/notepad.gif
--------------------------------------------------------------------------------
/src/images/price.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/price.png
--------------------------------------------------------------------------------
/src/images/ware.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/images/ware.png
--------------------------------------------------------------------------------
/src/model/AgeCategory.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | public enum AgeCategory {
4 | Nissan,
5 | Mazda,
6 | Land_Rover,
7 | Lada,
8 | Honda
9 | }
10 |
--------------------------------------------------------------------------------
/src/model/Database.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 |
4 |
5 | import java.io.File;
6 | import java.io.FileInputStream;
7 | import java.io.FileOutputStream;
8 | import java.io.IOException;
9 | import java.io.ObjectInputStream;
10 | import java.io.ObjectOutputStream;
11 | import java.sql.Connection;
12 | import java.sql.DriverManager;
13 | import java.sql.PreparedStatement;
14 | import java.sql.SQLException;
15 | import java.sql.Statement;
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.Collections;
19 | import java.util.LinkedList;
20 | import java.util.List;
21 |
22 | import com.mysql.jdbc.ResultSet;
23 |
24 | public class Database {
25 |
26 |
27 | private List people;
28 |
29 | private Connection con;
30 |
31 |
32 | public Database() {
33 | people = new LinkedList();
34 |
35 | }
36 | public void connect() throws Exception
37 | {
38 | if(con != null) return;
39 | try {
40 | Class.forName("com.mysql.jdbc.Driver");
41 | } catch (ClassNotFoundException e) {
42 | throw new Exception("Driver not found");
43 | }
44 |
45 | String url = "jdbc:mysql://localhost:3306/swingtest_oleh";
46 | con = DriverManager.getConnection(url,"root","");
47 |
48 |
49 |
50 |
51 |
52 | System.out.println("successful connected : " + con);
53 |
54 | }
55 |
56 |
57 |
58 | public void disconnect()
59 | {
60 | if(con != null)
61 | {
62 | try {
63 | con.close();
64 | } catch (SQLException e) {
65 | System.out.println("Cant close");
66 | }
67 | }
68 |
69 | }
70 |
71 |
72 |
73 | public void save() throws SQLException
74 | {
75 | String checkSql = "select count(*) as count from people where id=?";
76 | PreparedStatement checkStmt = con.prepareStatement(checkSql);
77 |
78 | String insertSql = "insert into people (id , name , age , employment_status, tax_id , us_citizen ,gender, occupation) values (? , ? , ? , ? , ? , ? , ? ,? ) ";
79 | PreparedStatement insertStatement = con.prepareStatement(insertSql);
80 |
81 | String updateSql = "update people set name=?, age=?, employment_status=?, tax_id=?, us_citizen=?, gender=?, occupation=? where id=?";
82 | PreparedStatement updateStatement = con.prepareStatement(updateSql);
83 |
84 |
85 | for(Person person: people)
86 | {
87 | int id = person.getId();
88 | String name = person.getName();
89 | String occupation = person.getOccupation();
90 | AgeCategory age = person.getAgeCategory();
91 | EmploymentCategory emp = person.getEmpCat();
92 | String tax = person.getTaxId();
93 | boolean isUs = person.isUsCitizen();
94 | Gender gender = person.getGender();
95 |
96 |
97 | checkStmt.setInt(1, id);
98 |
99 | ResultSet checkResult = (ResultSet) checkStmt.executeQuery();
100 |
101 | checkResult.next();
102 |
103 | int count = checkResult.getInt(1);
104 |
105 | if(count == 0 )
106 | {
107 | System.out.println("inserting person with ID : "+id);
108 |
109 | int col = 1;
110 | insertStatement.setInt(col++, id);
111 | insertStatement.setString(col++, name);
112 | insertStatement.setString(col++, age.name());
113 | insertStatement.setString(col++, emp.name());
114 | insertStatement.setString(col++, tax);
115 | insertStatement.setBoolean(col++, isUs);
116 | insertStatement.setString(col++, gender.name());
117 | insertStatement.setString(col++, occupation);
118 |
119 | insertStatement.executeUpdate();
120 |
121 |
122 |
123 |
124 |
125 | }
126 | else
127 | {
128 | System.out.println("Updating person with ID" + id);
129 |
130 | int col = 1;
131 |
132 |
133 | updateStatement.setString(col++, name);
134 | updateStatement.setString(col++, age.name());
135 | updateStatement.setString(col++, emp.name());
136 | updateStatement.setString(col++, tax);
137 | updateStatement.setBoolean(col++, isUs);
138 | updateStatement.setString(col++, gender.name());
139 | updateStatement.setString(col++, occupation);
140 | updateStatement.setInt(col++, id);
141 |
142 | updateStatement.executeUpdate();
143 | }
144 | System.out.println("Count for person with id : "+ id + " is " + count);
145 |
146 | }
147 |
148 | updateStatement.close();
149 | insertStatement.close();
150 | checkStmt.close();
151 | }
152 |
153 | public void load() throws SQLException
154 | {
155 | people.clear();
156 |
157 | String sql = "select id , name , age , employment_status, tax_id , us_citizen ,gender, occupation from people order by name ";
158 |
159 | Statement selectStatement = con.createStatement();
160 |
161 |
162 |
163 | ResultSet results = (ResultSet) selectStatement.executeQuery(sql);
164 |
165 | while(results.next())
166 | {
167 | int id = results.getInt("id");
168 | String name = results.getString("name");
169 | String age = results.getString("age");
170 | String emp = results.getString("employment_status");
171 | String tax = results.getString("tax_id");
172 | boolean isUs = results.getBoolean("us_citizen");
173 | String gender = results.getString("gender");
174 | String occ = results.getString("occupation");
175 |
176 |
177 | Person person = new Person(id,name,occ ,AgeCategory.valueOf(age),EmploymentCategory.valueOf(emp),tax , isUs , Gender.valueOf(gender));
178 | people.add(person);
179 |
180 |
181 | }
182 |
183 | results.close();
184 | selectStatement.close();
185 |
186 | }
187 | public void addPerson(Person person) {
188 | people.add(person);
189 | }
190 | public void removePerson(int index)
191 | {
192 | people.remove(index);
193 |
194 | }
195 |
196 | public List getPeople() {
197 | return Collections.unmodifiableList(people);
198 | }
199 | public void saveToFile(File file) throws IOException
200 | {
201 | FileOutputStream fos = new FileOutputStream(file);
202 | ObjectOutputStream oos = new ObjectOutputStream(fos);
203 |
204 | Person[] persons = people.toArray(new Person[people.size()]);
205 |
206 | oos.writeObject(persons);
207 |
208 | oos.close();
209 | }
210 | public void loadFromFile(File file) throws IOException
211 | {
212 | FileInputStream fis = new FileInputStream(file);
213 | ObjectInputStream ois = new ObjectInputStream(fis);
214 |
215 | try {
216 | Person[] persons = (Person[]) ois.readObject();
217 |
218 | people.clear();
219 |
220 | people.addAll(Arrays.asList(persons));
221 |
222 |
223 | } catch (ClassNotFoundException e) {
224 | // TODO Auto-generated catch block
225 | e.printStackTrace();
226 | }
227 |
228 | ois.close();
229 |
230 | }
231 | }
232 |
--------------------------------------------------------------------------------
/src/model/EmploymentCategory.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlmn/simple-java-crud-app/1ae2681e629c0bc5efec3e2842b1113375cc7bc5/src/model/EmploymentCategory.java
--------------------------------------------------------------------------------
/src/model/Gender.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | public enum Gender {
4 | yes,
5 | no
6 | }
7 |
--------------------------------------------------------------------------------
/src/model/Person.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | import java.io.Serializable;
4 | import java.net.URL;
5 |
6 | import javax.swing.ImageIcon;
7 | import javax.swing.table.DefaultTableCellRenderer;
8 |
9 | public class Person extends DefaultTableCellRenderer implements Serializable
10 | {
11 | private static final long serialVersionUID = 4022843652518158650L;
12 |
13 | private static int count = 1;
14 |
15 | private int id;
16 | private String name;
17 | private String occupation;
18 | private AgeCategory ageCategory;
19 | private EmploymentCategory empCat;
20 | private String taxId;
21 | private boolean usCitizen;
22 | private Gender gender;
23 | private ImageIcon personIcon;
24 |
25 | public Person(String name, String occupation, AgeCategory ageCategory,
26 | EmploymentCategory empCat, String taxId,
27 | boolean usCitizen, Gender gender) {
28 | this.name = name;
29 | this.occupation = occupation;
30 | this.ageCategory = ageCategory;
31 | this.empCat = empCat;
32 | this.taxId = taxId;
33 | this.usCitizen = usCitizen;
34 | this.gender = gender;
35 |
36 | this.id = count;
37 | count++;
38 | }
39 |
40 | public Person(int id, String name, String occupation, AgeCategory ageCategory,
41 | EmploymentCategory empCat, String taxId,
42 | boolean usCitizen, Gender gender) {
43 |
44 | this(name, occupation, ageCategory, empCat, taxId, usCitizen, gender);
45 |
46 | this.id = id;
47 |
48 | }
49 |
50 | public int getId() {
51 | return id;
52 | }
53 | public void setId(int id) {
54 | this.id = id;
55 | }
56 | public String getName() {
57 | return name;
58 | }
59 | public void setName(String name) {
60 | this.name = name;
61 | }
62 | public String getOccupation() {
63 | return occupation;
64 | }
65 | public void setOccupation(String occupation) {
66 | this.occupation = occupation;
67 | }
68 | public AgeCategory getAgeCategory() {
69 | return ageCategory;
70 | }
71 | public void setAgeCategory(AgeCategory ageCategory) {
72 | this.ageCategory = ageCategory;
73 | }
74 | public EmploymentCategory getEmpCat() {
75 | return empCat;
76 | }
77 | public void setEmpCat(EmploymentCategory empCat) {
78 | this.empCat = empCat;
79 | }
80 | public String getTaxId() {
81 | return taxId;
82 | }
83 | public void setTaxId(String taxId) {
84 | this.taxId = taxId;
85 | }
86 | public boolean isUsCitizen() {
87 | return usCitizen;
88 | }
89 | public void setUsCitizen(boolean usCitizen) {
90 | this.usCitizen = usCitizen;
91 | }
92 | public Gender getGender() {
93 | return gender;
94 | }
95 | public void setGender(Gender gender) {
96 | this.gender = gender;
97 | }
98 |
99 | public String toString()
100 | {
101 | return id + "Name: "+ name;
102 | }
103 |
104 | public ImageIcon getPersonIcon() {
105 |
106 | personIcon = new ImageIcon(new String("/images/car.png"));
107 | return personIcon;
108 | }
109 |
110 | public void setPersonIcon(ImageIcon personIcon) {
111 | this.personIcon = personIcon;
112 | }
113 | private ImageIcon createIcon(String path)
114 | {
115 | URL url = getClass().getResource(path);
116 |
117 | if(url == null)
118 | {
119 | System.err.println("Unabled to load image"+path);
120 | }
121 |
122 | ImageIcon icon = new ImageIcon(url);
123 |
124 | return icon;
125 | }
126 |
127 |
128 |
129 | }
130 |
--------------------------------------------------------------------------------