Saturday, January 25, 2014

Example of Frame Location in java.

////This will center the Frame in the middle of the screen.

import java.awt.*;
class mahi1
{
mahi1()
{
Frame f=new Frame("MaHi");
Label l1=new Label();
l1.setText("Best since day one");
l1.setAlignment(Label.CENTER);
f.add(l1);

f.setSize(300,300);
f.setVisible(true);
f.setLayout(new GridLayout(1,1));
f.setLocationRelativeTo(null);
}
public static void main(String surat[])
{
new mahi1();
}
}

Output:

No comments:

Post a Comment