by Dinesh Thakur Category: AWT and Applets

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);
      }
  }


About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article