All About Class Label in AWT in Java

0
127
Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

Class Label in AWT in Java

Label are String representation of a display text.A label is a component for placing text in a container.The text can be changed by the application but user can not edit it.

This class is a Component that displays a single specified line of read – only text. The constant values specify the text alignment within the component and may be specified to the constructor or to setAlignment ().

The class structure of Label is given as below:

public class java.awt.Label extends java.awt.Component{
//member elements:
public final static int CENTER;//indicates that the label should be centered.
public final static int LEFT;//indicates that the label should be left justified.
public final static int RIGHT;//indicates that the label should be right justified.
//constructors
public Label();//default constructor creates an empty label whose label is left justified
public Label(String label)//creates a label with the specified argument whose label is left justified
public Label(String label,int alignment);//creates a label with the specified argument and alignment 
//alignment could be Label.CENTER ,Label.LEFT or Label.RIGHT
//methods
public void addNotify();// Overrides Component
public int getAlignment();
public String getText();
protected String paramString();// Overrides Component
public synchronized void setAlignment(int alignment);
public synchronized void setText(String label);
 }
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here