Label Assignment Help

Assignment Help: >> Controls and Events - Label

Label:

A label is a component which shows a single line of read-only, non-selectable text.  It does not produce any special events. A label class declares three constructors

Label ( )

Label (String text)

Label (String text, int alignment)

The alignment of the label in a container could be specified through the following constants of the Label class. The default alignment of label is left.

public static final int LEFT

public static final int CENTER

public static final int RIGHT

The Label class declares accessor methods for reading the current text and modifying the text in a label:

String getText ( )

void setText(String text)

There are also accessor methods for reading the current alignment and setting a particular alignment for a label:

int getAlignment ( )

void setAlignment( int alignment)

Instance demonstrates two Labels, one along with default (left) alignment and another along with centered.

// Illustrating Labels

import java.awt.*;

import java.applet.*;

public class LabelApplet extends Applet

{

public void init ( )

{

setLayout(new GridLayout(2,1);

add(new Label("A sticky label");

add(new Label("One more sticky label", label.CENTER);

}

}

2221_Label.png

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd