Java is the future !: Java tutorial
Showing posts with label Java tutorial. Show all posts
Showing posts with label Java tutorial. Show all posts

Saturday, August 14, 2010

Chapter 2: Positioning text version pt.1

Just as we did with the previous program it displays as label. It is identical to the previous one with a single exception that the TextOne object is displayed instead of the Label object.

What is a TextOne object?

It's not part of the standard library like the label was. This is a class of our own. A Canvas object is a displayable component just like a label except the Canvas object doesn't do anything but provide a blank window and permission to draw graphics of our own. So the TextOne class extends the Canvas class and adds a method to draw a single line of text.

The paint method is called by java whenever TextOne object needs to be displayed. Whenever the TextOne window first appears the paint method is called to draw the content of the window. (Paint method is called again if any changes happens like size change etc to redraw the window)

Graphics object is passed to paint method.

Setsize method specifies the original size of the window.




Chapter 2: Font anatomy

Chapter 1: Adding exits to Howdy Window

In the previous program the window that we made was not closing, to overcome that problem we have to add some new methods to our class. Here's the source code.




Chapter 1: The source code of a Howdy Window