////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:
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