Unit 4: Using AWT controls, Layout Managers, and Menus
4.2.1Label The object of Label class is a component for placing text in a container. It is used to display a single line of read only text. The text can be changed by an application but a user cannot edit it directly. Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import java.awt.*; class LabelExample{ public static void main(String args[]){ Frame f= new Frame("Label Example"); Label l1,l2; l1=new Label("First Label."); l1.setBounds(50,100, 100,30); l2=new Label("Second Label."); l2.setBounds(50,150, 100,30); f.add(l1); f.add(l2); f.setSize(400,400); f.setLayout(null); f.setVisible(true); } } |
output:- Button The button class is used to create a labeled button that […]
Continue Reading