Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[110918]: htdocs / applets / label.ht Maximize Restore History

Download this file

label.ht    31 lines (23 with data), 849 Bytes

Title: Label Example

<h3>Using Labels</h3>

<p>This example shows how to use Labels from Jython.
<p>
<applet code="LabelDemo" archive="appletdemo.jar" width = 150 height = 100
        alt="This browser doesn't support JDK 1.1 applets.">
<h3>Something has gone wrong loading this applet.</h3>
</applet>

<p>The complete source code for this example is included below.

<blockquote><pre><hr>
from java import applet
from java.awt import Label, GridLayout

class LabelDemo(applet.Applet):
    def init(self):
        self.setLayout(GridLayout(0,1))
        self.add(Label('Left'))
        self.add(Label('Center', Label.CENTER))
        self.add(Label('Right', Label.RIGHT))
<hr></pre></blockquote>


Three labels are created with different alignments.  The first has 
the default left alignment and the other two are centered and right 
aligned.

<p>