Showing posts with label Methods. Show all posts
Showing posts with label Methods. Show all posts

Monday, 3 March 2014

AWT CONTROLS IN JAVA:LABELS

AWT Label Class

Create AWT Label with simple Example..........

INTRODUCTION

Label component displays text just like a drawString(). The difference is Label gets the status of a component so that it can be added in position format using layout manager. Label displays text in one line only. User cannot edit the text of the label. It is meant only for the programmer to display some information. The label does not raise any events (the other only component that does not raise events is Panel). 

FIELDS

Following are the fields for java.awt.Component class:
  • static int CENTER
  • static int LEFT 
  • static int RIGHT 

public static final int LEFT = 0       label is aligned to left
public static final int CENTER = 1 label is aligned to center
public static final int RIGHT = 2         label is aligned to right

Tuesday, 21 January 2014

INTRODUCING final

In Java class can be declared as final using final keyword. If the final keyword is used in the class declaration the class becomes unable to be sub-classed. No any class can extend the final class i.e. features of a final class can't be inherited. Various classes of Java library are defined as final fro example java.lang.String, java.lang.System etc. If a final class contains the methods then these methods becomes final implicitly. In Java classes are declared as final for the security and efficiency reason. final makes the class immutable.

Sunday, 19 January 2014

INTRODUCING METHODS

In java,there are some fundamentals that you need to learn now so that you can begin to add methods to your classes.Although it is perfectly fine to create a class that contains only data,it rarely happens.Most of the time you will use methods to access the instance variables defined by the class.

DIFFERENT TYPE OF VARIABLES IN JAVA

A class can contain any of the following variable types.
                           1.Local Variables
                           2.Instance variables
                           3.Class variables