Create a Label and set the text alignment import java.awt.*; import java.applet. *; public class LabelDemo extends Applet { public void init() { setLayout(null); int width = Integer.parseInt(getParameter("width")); int height = Integer.parseInt(getParameter("height")); Label left = new LabelC'Left", LabeLLEFT); Label right = new Label("Right", LabeLRIGHT); Label center = new Label("Center", Label.CENTER); add(left); add(right); add(center); left.reshape(0, 0, width, height / 3); right.reshape(0, height / 3, width, height / 3); center.reshape(0,2 * height / 3, width, height / 3); } }
To simultaneously move and resize objects Label, we used the method reshape. Create a text field with no text public Label(); Create a text field with the specified text public Label(String label); Create a text field with the specified text and the specified alignment public Label(String label, int alignment); Create a class field Label Label lbTextLabel; lbTextLabel = new Label("Board game Oflameron"); Using the add method, you can add a text box in the applet window: add(lbTextLabel); Read More Detail >>>> Next Page >>>> Keywords: - free, java, ebook, Java tutorial Description: - Free Java guide. Free ebook About: - Free board game on Java "Oflameron". Free ebook