Computer Science Canada

[Tutorial] Swing by example

Author:  McKenzie [ Fri Mar 18, 2005 9:57 am ]
Post subject:  [Tutorial] Swing by example

I am by no means claiming to a Swing master. I just know that when I'm learning something new I like to have a bunch of simple examples. Ones that you can get your head around so that you can focus on the one small thing you are trying to add to your knowledge. If any of these examples contradict what Rizz has said odds are he's right Embarassed

Author:  wtd [ Fri Mar 18, 2005 2:12 pm ]
Post subject: 

A note: many of the classes will not run because they lack entry points (main).

Additionally, Swing12 claims to correct something in Swing11, yet when run both appear identical. This could be very confusing.

Some programs, when run, and upon clicking the close button, do not exit. Again, this could be very confusing for someone unfamiliar with how to interrupt the program, or who isn't using the command-line to run them.

Oh, one other thing. Avoid method calls that look like:

code:
myMethod ();


Though this works, the preferred coding style for Java is:

code:
myMethod();


It's good to encourage this because at least a few languages students may encounter later allow arguments with and without parentheses. In these languages if there's a space, it perceives the parentheses as simply surrounding the first argument to the function.

Author:  McKenzie [ Fri Mar 18, 2005 2:38 pm ]
Post subject: 

Swing1 is the only one that lacks a main. In the IDE that 90% of the students use (Ready) it will set up a dummy main. I was just trying to boil it down to the absolute bare-bones.
Swing11 allows you to select all of the days independantly of each other, Swing12 fixes that.
The not closing issue: I like to point out the problem before we add the fix.
As far as the spacing goes, the Ready IDE has an auto-indent feature. Because I'm fairly new to Java I've been relying on it to decide where the spaces should go (well sometimes.)

Author:  wtd [ Fri Mar 18, 2005 2:40 pm ]
Post subject: 

McKenzie wrote:
Because I'm fairly new to Java I've been relying on it to decide where the spaces should go (well sometimes.)


It's wrong. Smile


: