Customers Java Swing Application with Source Code

customersdesktop

I have developed the Customers Java Swing Application Demo. This application may be useful for developers who want to use Flamingo, Substance and SwingX.

Technology stack:

Model View Controller (MVC) vs Model View Presenter (MVP):

The Customers Java Swing Application Demo has MVC design pattern such as Java Swing. MVP is also popular for Desktop and RIA. Which is best, there are many discussions. Martin Fowler has written very good explanations for GUI Architectures. You may like to read.

Models and Services:

I have written entities with NamedQueries in JPA and Hibernate. The services are very simple with Generic AbstractService.

Screenshots:

Full source code on Bitbucket

* Customers Java Swing Application images and icons credit: iconsdb.com and icons8.com

34 Comments

  1. Arian
    Jul 25, 2014 @ 08:08:00

    What is the version of the Flamingo that this example used? I downloaded the source from the project in github but the packages is different. The one that you are using also have slider package which is not available in the github source.

    I would like to have the doc jar, where could I found it for the version you are using?

    Thank you.

    Reply

    • Cem Ikta
      Jul 25, 2014 @ 21:55:56

      Hi,

      This demo use Flamingo-Version: 4.1final Guenivere, Flamingo-BuildStamp: May 24, 2009 11:57:06 PDT (you can find in flamingo.jar > META-INF > manifest.mf file). I have Flamingo and Substance libs from flamingo.dev.java.net, substance.dev.java.net, substance-flamingo.dev.java.net. This project sites were closed, details here.

      Unfortunetly, I haven’t javadocs from Flamingo and Substance libs.

      Best regards.

      Reply

  2. Ilhama
    Nov 16, 2014 @ 23:25:41

    Hi.I can work this project my computer.i am download project on bitbucket and istall MySql 5.5 .How to work project ?

    Reply

  3. hrama
    Nov 29, 2014 @ 05:25:55

    Hi. Great Project!
    I have a question to do, you are using reflection to get values from the class EntityTableColumn but this have a problem when the objects have inherited fields.
    Is there any way to get the inherited fields?

    Reply

    • Cem Ikta
      Nov 29, 2014 @ 20:10:02

      Hi,

      You can set your class type in your EntityTableColumn as below:


      getTableModel().addColumn(new EntityTableColumn(
      I18n.CUSTOMERS.getString("Customer.Page.Category"),
      "category", Category.class, 200));

      Reply

  4. hrama
    Nov 30, 2014 @ 07:29:39

    Thanks For the answer!
    Perhaps I was not clear on the question.
    When i use the Entity Table Column with object with inherited Fields i have an error in the line

    Field field = entity.getClass().getDeclaredField(getFieldName());
    field.setAccessible(true);

    The error is java.lang.NoSuchFieldException: name.
    This is because the getDeclaredField method don’t support inherited fields, my question is if there is a way to obtain that field

    Reply

    • Cem Ikta
      Dec 01, 2014 @ 18:11:49

      As far as I know, it should work, if that field has getters and setters. Can you write code snippet? then I can test in my project.

      Reply

  5. Abhinandan
    Jan 21, 2015 @ 12:54:36

    Please give me link to download project

    Reply

    • Cem Ikta
      Jan 21, 2015 @ 22:55:08

      Customers Java Swing Project source code hosted on Bitbucket, you can fork or download all files from the repository!

      Reply

  6. khem nem
    Jun 02, 2015 @ 06:59:31

    how do i display id in table?

    Reply

    • Cem Ikta
      Jun 02, 2015 @ 21:18:32

      You can add Id column in Page View e.g CategoryPage#addTableColumns method.

      getTableModel().addColumn(new EntityTableColumn( I18n.CUSTOMERS.getString("Category.Page.Id"), "id", Long.class, 150));

      Reply

  7. khem nem
    Jun 02, 2015 @ 07:05:57

    how do i filter by id?

    Reply

  8. khem nem
    Jun 06, 2015 @ 15:40:49

    Hello Cem Ikta, Can you write code snippet about filter by id?

    I have problem with with(“id”, “%” + filter + “%”)

    Reply

  9. khem nem
    Jun 06, 2015 @ 16:47:00

    Thank for reply me! but getTableModel().addColumn(new EntityTableColumn( I18n.CUSTOMERS.getString(“Category.Page.Id”), “id”, Long.class, 150)); not work it has error like this
    com.devsniper.desktop.customers.framework.EntityTableColumn getValue
    SEVERE: null
    java.lang.NoSuchFieldException: id
    at java.lang.Class.getDeclaredField(Class.java:1953)

    Reply

  10. bonny sebastian
    Jul 03, 2015 @ 06:42:02

    plz tell me how to import database content to mysql of this current project…….. whenever i import it shows sql dump import error… plz tell me how can import data to mysql and run my project successfully .
    thankyou.

    Reply

  11. Evanson
    Feb 04, 2016 @ 06:58:08

    Hi Cem.GreatProject.I have been reading your code and i see you have extensively used mvc pattern.However am not getting an overview hierarchical dagram of the system.Could you by any chance be having any rough architectural diagrams of the project.Am currently learning how to implement the mvp and mvc patterns in my swing projects.

    Reply

    • Cem Ikta
      Feb 05, 2016 @ 00:06:50

      Hi,

      I haven’t UML diagrams, but I try to explain:

      Services and Models:
      Models are entities (not POJOs) in my project. It is simple so and all entities extends BaseEntity for common fields and base functions.
      Services are extends AbstractService, my services have not DAO layer, because the project has only one data source and not complex business logic.

      Application:
      AppController: the application starter controller, creates main view (AppView)
      AppView: main view and its components extends JRibbonFrame (not JFrame because of ribbon components)
      CustomersDesktop is swing main class for project and extends AppController.

      Controllers and Views:
      There are four types of views: PageViews, DataPageViews, FormViews and PreviewPanel.
      PageView: A page view is typically extends JPanel and it has no data components with templates such as DashboardPage, it is always center panel of AppView.
      DataPageView: A page view with search, table, optional preview panel and it has data components with entities such as CustomerPage. it is always center panel of AppView.
      PreviewPanel: A JPanel preview panel, optional in DataPageViews, PreviewPanel shows the details of selected item from table such as CustomerPreview.
      FormViews: A modal JDialog form view, it is typically editor form view such as CustomerForm.

      Each controller must have at least one view but can have multiple views e.g. DashboardController has only DashboardPage and CustomerController has CustomerPage and CustomerForm. Every view must have a controller! Why? Does it make sense? If you have one controller and one view, it is complicated to control views!

      I hope it helps.

      Good luck with your project.

      Reply

  12. peta
    Feb 05, 2016 @ 05:40:11

    good project , guys lets me know ..where is code for sql query

    Reply

    • Cem Ikta
      Feb 05, 2016 @ 05:51:00

      Please see db folder.

      Reply

      • peta
        Feb 06, 2016 @ 01:07:02

        thanks i got i it , btw if we build the application to jar file ,everyone can get username and password mysql server with open jar file use winrar and pick persistence.xml .. do you have solution to encrypted username and password ? and how to application (jar file) can read configuration.properties (eksternal file ) in same directory with jar file to get config of mysql server

        Reply

  13. Berto
    Feb 28, 2016 @ 12:13:09

    Wow good looking .. , i will use this to develop my first java application , @cem ikta i has been read source code , but i don’t know ..how to create login user .i need : 1st > Login Form 2nd > User Interface (base on level ),priveleges operator and manager is different and display username loggin in statusbar. do you have source code for login base on user level ? . thanks

    Reply

    • Cem Ikta
      Feb 29, 2016 @ 12:39:08

      Hi,

      you have to create 2 classes: LoginController(implements Controller) LoginDialog(extends JDialog). You can show login dialog in AppController (line 65) and you can set logged user in AppController(setLoggedUser, getLoggedUser, setStatusBarUser).

      Reply

  14. Berto
    Mar 01, 2016 @ 13:44:19

    hi cem ikta,
    i has create Login dialog (create at com.devsniper.desktop.customer.componen) , and add LoginDialog.showDialog(); in appcontroller . but i still not understand about LoginController(implements Controller) .AppController(setLoggedUser, getLoggedUser, setStatusBarUser). can you explain to me (with sample sourcode ) ?. thank you very much.

    Reply

    • Cem Ikta
      Mar 15, 2016 @ 12:20:23

      Sorry for late answer. You have to create a controller for your every view and a controller creates its view. A simple LoginController implements Controller interface such as DashboardController. If your login successful, you can set logged user in AppController then you have access logged user via AppController everywhere in your application like AppController.get().getLoggedUser(). If you want to set your logged user in your AppView statusbar, then create a method in AppView setStatusBarLoggedUsername(User user).

      Reply

  15. Wira
    Mar 14, 2016 @ 17:16:34

    Hi cem ikta , i need to modify connection pool in customer desktop use hibernate c3p0 .. i has import library hibernate-c3p0-4.3.7.Final.jar ,upgrade hibernate-core-5.0.6.Final.jar and modify JPAUtil :
    public static EntityManagerFactory getEntityManagerFactory() {

    Map props = new HashMap();
    props.put(“hibernate.dialect”,”org.hibernate.dialect.MySQL5InnoDBDialect”);
    props.put(“hibernate.connection.url”, “jdbc:mysql://localhost:3306/dbxx”);
    props.put(“hibernate.connection.username”, “root”);
    props.put(“hibernate.connection.password”, “”);
    props.put(“hibernate.show_sql”, “true”);
    props.put(“hibernate.format_sql”, “true”);
    props.put(“hbm2ddl.auto”, “validate”);
    props.put(“hibernate.connection.drive_class”, “com.mysql.jdbc.Driver”);
    props.put(“hibernate.c3p0.max_size”, “31″);
    props.put(“hibernate.c3p0.timeout”, “300″);
    props.put(“hibernate.c3p0.max_statements”, “50″);
    props.put(“hibernate.c3p0.idle_test_period”, “1000″);
    props.put(“hibernate.c3p0.validate”, “true”);
    props.put(“hibernate.connection.provider_class”, “org.hibernate.c3p0.internal.C3P0ConnectionProvider”);
    if (emf == null) {
    emf = Persistence.createEntityManagerFactory(“APPnew”,props);
    }
    return emf;
    }

    after run the program i got error:

    Mar 14, 2016 9:57:46 PM org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator instantiateExplicitConnectionProvider
    INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.c3p0.internal.C3P0ConnectionProvider
    Mar 14, 2016 9:57:46 PM org.hibernate.c3p0.internal.C3P0ConnectionProvider configure
    INFO: HHH010002: C3P0 using driver: null at URL: jdbc:mysql://localhost:3306/dbxx
    Exception in thread “AWT-EventQueue-0″ java.lang.NoSuchMethodError: org.hibernate.c3p0.internal.C3P0MessageLogger.connectionProperties(Ljava/util/Properties;)V
    at org.hibernate.c3p0.internal.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:134)

    can you help me to solved this problem ? . thank you.

    Reply

Leave a Reply