Programming Examples

Are you a Programmer or Application Developer or a DBA? Take a cup of coffee, sit back and spend few minutes here :)

Tag Archive for ‘paint’

Creating AWT Flash Window

About the AWT Flash Window Example

The below picture shows the example which we will create here. In the AWT Frame, we will display only one button. The button Do Task will open a AWT Window which shows a status message for a small while. This window is a sign to the user that some processing is going on. But our example mimics the long-running task with the ‘Thread.sleep’ method.

After a few seconds, the window closes automatically. You can use this same example to create a flash window. Here, we displayed some text in the window. In a flash window, you can display an image to show your brand.

Continue Reading →

FreeHand Drawing: AWT Drawing – Part 4

FreeHand Drawing: Chaining of P1 and P2 between Reported Drag Events

But for Free-Hand drawing, we should not wait till mouse release. We should draw while the mouse is dragged. This means we need to arrange the points P1 and P2 on each reported drag event. In the first part of the below picture, the Red Cross line shows the MouseEvent which AWT reports to the listener. We can still use the drawLine API and connect the currently reported point with the previous one. The net effect is a smooth curve even-though what we draw is a straight line in small chunks. Note, AWT reports the drag events so quickly and hence user will not see the straight inter-connected lines.

Continue Reading →