Login    New User    Forgot Password    Help      

Border Layout Using Insets

Java Tutorials

Example

// Border Layout ( using insets)
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="control11" width=250 height=300>

</applet>
*/

public class control11 extends Applet

{

public void init()

{
// change the back color to see the changes easily
setBackground(Color.cyan);

setLayout (new BorderLayout ());

add(new Button("Top of the Program"), BorderLayout.NORTH);
add(new Label("Footer message"), BorderLayout.SOUTH);
add(new Button("Right"),BorderLayout.WEST);
String str= "This is First line in java text field \n"+
"This is Second line in java text field \n"+
"This is third line in java text field \n"+
"This is Last line in java text field";
add(new TextArea(str),BorderLayout.CENTER);
}
// add insets
public Insets getInses()
{
return new Insets(10,10,10,10);
}
}

Output

Output in Applet

Java Tutorials