I am moving on to writing more applets. These are simple programs to get my bearings. The most important methods in JApplet are init() and paint(). You add items or objects to the screen in the init() function. And you draw things such as labels and buttons in the paint() function.
If you handle some GUI events like button clicks, the pattern is to call repaint() to get the screen updated based on the user input. It is funny how quickly I forget my Java basics when I do not code for a long time. These rules have not been committed to heart.
For example, I had to rediscover how to convert a String to an int. You create an Integer object, passing the String into the constructor. Then you can assign the resulting Integer to a variable of type int. Also you need to qualify Math package functions with "Math." to get your Java to compile.
Some topics are universal. Break down complex routines into multiple subroutines (functions). Make use of constants instead of magic numbers. In Java this is done with public static final variables. I will say I am starting to get some bearings on how to do drawing on the Canvas. The upper left hand corner of the screen has coordinates (0,0). Increasing x goes to the right. Increasing y goes down.
Reproducing a Race Condition
-
We have a job at work that runs every Wednesday night. All of a sudden, it
aborted the last 2 weeks. This caused some critical data to be late. The
main ...
2 years ago