Learning Swing with the NetBeans IDE

This is where the tutorial begins to get interesting, and for me it was the launch pad to my own first Java applet. I even like the form of the example. It not only contains the essential components of a GUI, but also a tiny bit of mathematics, and it performs a calculation which many of us perform in our head from time to time (if we come from an Anglo-Saxon culture with continental European influences).

The lesson Setting up the Celsius Converter Project is important to read very slowly. Stuff this up and you stuff up your whole project. I think there might be a mistake in it. Certainly I made a mistake on my first run through, and it did stuff me right up.

In Step 1: Create a New Project, the instructions are just fine. Step 2 is fine. Step 3 is also fine in so far as it goes. Obviously if you are using the lesson as a guide for your own custom project you will choose a name which suits you, but that is not the main issue. The main issue here is that nothing is said about packages.

I know I criticised earlier lessons for introducing the package concept too early, but that is because I was using the early lessons to learn Java commands and syntax, and I was not then interested in building a whole application. The situation is now reversed. These lessons are about building an application, albeit a small one, and this when the learner needs to be thinking about placing his or her work in the context of a larger structure.

So I am quite surprised that there is not a reference to packages here, and I am even more surprised that the the create project dialog box does not offer an invitation to assign the project to a package.

Perhaps the answer comes in Steps 4 and 5. Here one is invited to assign the new JFrame to a package. The instruction is in very small print and would be easy to miss or gloss over. There is no mention of the significance of packages or the implications of assigning a class to the wrong package.

In VB, the project or project location is all important. What Java calls a JFrame, VB calls a form, and the file defining the form sits in the project folder, and can be used or dropped by the project, or indeed used by future projects, located in the same folder. So in VB, if you stuff up a project and need to start a new one, you can still use all the graphics created in the first incarnation of the project, without having to think too hard. Obviously you can reuse code in Java (that's what packages and classes are all about), but if you don't assign a class to a package correctly in the first place, using it all may be difficult, and using it in future projects may be nearly impossible.

Comments

Popular posts from this blog

A few notes on JavaScript

Forum Comments on Java Applets

Creating a Custom Swing Component