Displaying a custom dialog

Hi

I've created a couple of custom dialogs (each dialog is a separate class extending JDialog) which I want to display when a certain event occurs in my MainWindow. NetBeans 5.0 tells me that the show-method in JDialog has been deprecated and I haven't found any other 'suitable' method to display the dialogs. So, how do I display my dialogs?

Also, I'm rather new to GUI-programming and I'd appreciate if anyone could recommend any sites or books about best practices regarding Java Swing GUI.

[519 byte] By [GlurGa] at [2007-10-3 2:44:47]
# 1

> NetBeans 5.0 tells me that the show-method in JDialog has been deprecated and I haven't found any other 'suitable' method to display the dialogs. So, how do I display my dialogs?

Used the setVisible(boolean b) method

> Also, I'm rather new to GUI-programming and I'd appreciate if anyone could recommend any sites or books about best practices regarding Java Swing GUI.

First tip: you should not be using IDE GUI Builders when your learning how to develop guis especially in java. It may be fast but it does not help the learning process.

Second Tip: There are several sites out there that provide sample code for almost any problem you can imagine (and there are these forums for the tricky stuff). You should search the net sometime before rushing to post a question.

Third Tip: Best Practices are obtained through Practice. You can subscribe to newsletter from sun and other know java sources for updates from time to time but what I have realised is that you'll build your own style of coding if you tend to practice what you love doing alot.

ICE

icewalker2ga at 2007-7-14 20:33:18 > top of Java-index,Desktop,Core GUI APIs...
# 2

> First tip: you should not be using IDE GUI Builders when your learning how to develop guis especially in java. It may be fast but it does not help the learning process.

Actually, I've had some experience building small (very small) GUI apps in java. I coded the GUI manually (without any GUI builder), and I remember that it was extremely tedious and error prone. I've not found any well established best practices how to actually develop GUI apps manually and it will probably take me a couple of month (or years) till I find some decent practices of my own :(

By the way, do the GUI-builders (like NetBeans) generate "good" code? Looking at my current project, I see that about 550 lines of GUI code has been generated for a somewhat trivial interface. 550 lines would've taken a lot of time to write manually (and get everything right). In NetBeans, it took about 30 minutes to lay out every component. However, those 550 lines could probably be squeezed into maybe 225 lines if done right manually...?

Does the majority of the java developers who develop non-trivial applications use gui-builders? Why/Why not?

> Second Tip: There are several sites out there that provide sample code for almost any problem you can imagine (and there are these forums for the tricky stuff). You should search the net sometime before rushing to post a question.

Yes, there are lots of sites out there that provide sample code, but the problem is that I don't really 'trust' the majority of them.

I've coded PHP for about 3-4 years now which has given me some insight into the community as well as a couple of best practices. And I can tell you that at least 97% of the code found on tutorial sites is absolute sh*t code. By sh*t code I mean for example global variables, no respect to MVC, hardly any database abstraction, no coding standard, improper use of classes, inefficient code etc etc.

I don't know how much this applies to the Java community, but my gut feeling tells me that any random tutorial about XYZ I happen to stumble upon isn't going to tell me how to really "do it right".

Anyhow, I've found a book which has a couple of these best practices I seek. The book is called "Effective Java", authored by Joshua Bloch.

Book recommendations about building GUI-apps are more than welcome.

GlurGa at 2007-7-14 20:33:18 > top of Java-index,Desktop,Core GUI APIs...
# 3

> By the way, do the GUI-builders (like NetBeans) generate "good" code? Looking at my current project, I see that about 550 lines of GUI code has been generated for a somewhat trivial interface. 550 lines would've taken a lot of time to write manually (and get everything right). In NetBeans, it took about 30 minutes to lay out every component. However, those 550 lines could probably be squeezed into maybe 225 lines if done right manually...?

That is exactly GUI builders are not good for beginners. They tend to add extra code in order for the components to display correctly in the IDE, not necessarily in java. Coding by hand gives you two things, 1. Experience and 2. Control Over The Code. You determine what goes in there and later when you need to make changes you can pin poin the problem easily and solve it.

It takes time to learn when you code by hand but the advantage would be that you would end up developing your own coding style and standard classes to help solve your problems.

And about getting code online, the reason you do not get very efficient code instanteneously is that no two people ever have the same problem. So the code may work for them 100% but only 65% in your case. It is up to who ever finds to code to tweak it slightly so it suits their needs.

[url http://www.geocities.com/icewalker2g]Here[/url] is my own site that provides some very very basic code for solving some common Swing and Java related problems. Each code can used on its own but you'll have to make some modification if you require it to do more.

ICE

icewalker2ga at 2007-7-14 20:33:18 > top of Java-index,Desktop,Core GUI APIs...