How does Java come to know where to place the component into the container. One possible way is to tell it manually. By manually, we mean that you have to specify the size and position of each component yourself.
import java.awt.*;
class setLayoutExample extends Frame
{
setLayoutExample()
{
setLayout(null);
Label lblRollno = new Label("Rollno : ");
lblRollno.setSize(50,120);
TextField txtRollno = new TextField(15);
txtRollno.setSize(50,120);
add(lblRollno); add(txtRollno);
}
}
class setLayoutJavaExample
{
public static void main(String args[])
{
setLayoutExample frame = new setLayoutExample();
frame.setTitle("Manually setLayout in Java Example");
frame.setSize(250,150);
frame.setVisible(true);
}
}