Skip to main content

Draft of Custom Desktop Database Tutorial

Posted by pkeegan on June 24, 2008 at 9:17 AM PDT

I have published a draft of an extended tutorial on creating desktop Java applications on netbeans.org. The tutorial is based on my recent series of blog posts. Thanks to everybody who provided questions and suggestions! A lot of them have been incorporated into the tutorial. Others are on my to-do list and are not forgotten.

The main things that appear in the tutorial that were missing from the blog are currency and date rendering and more customizations of table columns.

The tutorial needs some more polishing, but I think it's in a reasonably useful state. Let me know what you think.

By the way, I'm going on vacation tomorrow, so excuse the upcoming silence. Talk to you in three weeks.

Related Topics >>

Comments

creating custom java desktop database application

I have been following the article with some slight modifications, using three tables, one as the Master, and created two with Entity Classes from Database. I am getting an error in the two Entity classes that indicate "There is no ID defined for this entity hierarchy". The error indicates that the @ID is not present, but it is there. Everything appears ok. I suspect it has to do with JoinColums/OneToMany entries, I have experimented with variations from different sources, which only change the error. Sorry to reference this here. Can you suggest where I might get some help. I tried to register for the netbeans forums(requires a different ID), but I encounter problems with the spam box, and when I do get registered, it says it will send me an activation email. Which never is received. Tried mailing the webmaster but get no response.

creating custom java desktop database application

I have the same issue with the id hierarchy; I still can´t figure out what´s happening. Have you found a solution? Thank you!

Hi Patrick, Your tutorial has helped me a lot in learnig desktop application building, regarding persistence and beans binding. There was one thing I was unable to solve, and it has to do with jFormattedTextField binding: If we, for example, set the OrderEditor price formatted text field editable, as soon as we change the price value and the field looses focus, an java.lang.ClassCastException exception occurs, due to a convert reverse problem it seems. I checked out that the value of the formatted text field is used in the binding, instead of the text property. But I really could not make it work. I would thankfully receive any tips on how to correct this behavior, if you have the time.

Marc, You make good points. The Java Desktop Application project template is intended for simpler applications and thus does not do much of the work of separating out M, V, and C. One thing you might want to consider is using beans binding in conjunction with the NetBeans Platform (see the project templates in the NetBeans Modules category). There's more of a learning curve for NetBeans Platform applications, but you might find that the NetBeans Platform is a better framework for larger applications where you want to be more meticulous about MVC division - http://www.netbeans.org/kb/trails/platform.html

It works quite well…but... I have to move some methods (like save(), refresh()) if I want to manage new JInternalFrame classes not included in the mainframe. I’m using JInternalFrame instead of JDialog for the Customer Dialog and this generates some troubles (NullPointerException for the propertyChangeSupport.addPropertyChangeListener(listener) method). I want to build a real life application with about 40 entity classes and I am realizing that it is not simple at all with this framework. I think that beans binding is great but I’m a little bit disappointed when I see a big mix in the generated classes (i.e. the GUI methods are mixed with the Business methods and the data access methods within the same class..) I’m not sure this is really MVC compliant, what do you think?

Marc, Good question. For the MDI effect, you could try adding a JDesktopPane to the main panel and then add JInternalFrames to the JDesktopPane. Then, in the Inspector window cut the components in the main panel and paste them into the first JInternalFrame. Then use the other internal frames for the content that is in the tutorial's dialogs. You can then follow the steps in http://weblogs.java.net/blog/pkeegan/archive/2008/08/im_back_from_va.htm... to replace the modal behavior. Does that work?

MDI help

I want to launch my custom database application launch on a button click!I'M working hard donut but ther seems to be no way out!Would be grateful if somebody could provide with step by step tutorials how to make the database application launch inna button click!pls pls! Thanking in advance!

Hi Patrick, Thanks a lot for your very usefull tutorial : Creating a Custom Java Desktop Database Application. I am desperately looking for the same template with MDI windows support. I only found samples for Database application with a single window. I would like to have a Main MDI Application Frame with nothing on it and launch the customers managment window and orders management window from the Main frame menu. How can I manage this with Swing Application Framework, beans binding and JPA ? Thanks for your support. Best Regards Marc

I don't think the IDE's visual support enables you to generate entity classes based on views, but as far as I can tell, the Java Persistence API allows this. Perhaps you can hand-code some entity classes that use views instead of tables and build you application from there. BTW, what do you want to use views for? What is their advantage over using the tables directly?

Tutorials like yours are in short supply - thanks a lot Patrick - a great help. Am I correct in assuming that applying these approaches with a view as the source of you records is no different than accessing tables directly?

Hello Patrick, Very nice tutorial and easy to follow. Thank you so much for the tutorials. By the way, If I add NEXT/PREVIOUS buttons to my EditClient JDialog how do I display the next/previous data result to the EditClient Fields. Thanks in advance!

Thanks for your wonderful tutorials! I'd be lost without them and now have a very solid basic understanding of beans binding and have begun applying them immediately. I'd really like to see more tutorials with more complex examples. One in particular would be how to bind the results from a join from two tables. I have a feeling that this isn't possible from within netbeans yet.

Thank you, Patrick, for your tutorial. I would like to make it working with associations ManyToMany, however in this tutorial you have not talk about it, please if you can help me,I have a project which must be delivered soon. I 'm looking forward to hearing from you, Faithfully. .

Patrick thank you very much for your tutorial :)

The Bee's knees (English expression of appreciation I think) At last - an easy to follow tutorial that relates to real-life situations Thanks so much Mr Keegan - If I was in Prague I'd buy you a (probably several) beer(s) Next time you visit Yorkshire England..... Bye Jim Fergusson

Thank you, Patrick, for your tutorial. But screenshot in step 5 is from step 4. And in my NB6.1 radiobutton "Table" in step 5 is disabled :( And sorry for my english.

Thank you very much, i found your tutorial quite illuminating, much better than the rest of tutorials on the subject in the netbeans website

Hi duodecimo / Patrick Have you been able to solve the ClassCastException. I'm having a similar problem. I have managed to partly solve it. Also based my app on Patrick's tutorial. I am using a JFormattedTextField to display a price. Before setting the format to currency things seem to work. As soon as I set the formatter factory I get the ClassCastException like yourself. I found a post that partly resoves the issue, but I am not happy with it here.: http://www.nabble.com/Binding-JFormattedTextField-to-JTable-in-Java-Desk... Something else I found. It seems like the bound JFormattedTextField tries to convert String to double and double to String instead of BigDecimal. I discovered this when I implemented my own StringToBigDecimalConverter and added it under the advanced tab for the binding. I managed to resolve another issue with binding BigDecimal to Embedded Derbby DB. The BIgDecimal value was saved but everytime it would loose the decimal part. It turned out I had to modify the table field from DECIMAL (precision=10 scale=2) to (precision=16 scale=2). I have been banging my head for two days now with this problem. Still looking for the preferred solution.