Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Sunday 17 February 2019

Fourth Week Term Work Program1

1) Write a Java Program that creates an AWT window with the following attributes:
a. Dimensions of the window: 500X400
b. Initial position of the window: (150, 150)
c. Name of the window: My First AWT Frame
d. Add a button named “Cancel” to the window

Program:

import java.awt.Button;
import java.awt.Frame;
public class awtfirst {
awtfirst(){
Frame f=new Frame();
Button b=new Button("Cancel");
b.setBounds(150,150,150,150);
f.setTitle("My first Awt Frame");
f.add(b);
f.setLocation(150, 150);
f.setSize(500,400);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new awtfirst();
}
}

Output:


0 comments:

Post a Comment