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

Showing posts with label FOURTH WEEK LAB PROGRAM. Show all posts
Showing posts with label FOURTH WEEK LAB PROGRAM. Show all posts

Sunday, 17 February 2019

Fourth Week Term Work Program 3

3) Write a Java Program that creates an AWT window that should produce the following output when executed:






Program:

import java.awt.*;
import java.awt.event.*;
public class awtsecond extends Frame{
Button button1,button2,button3;
List l1;
TextField t1;
Label l;
Checkbox c1;
awtsecond(){
button1=new Button("RED");
button2=new Button("BLUE");
button3=new Button("WHITE");
button1.setBounds(20, 70, 70, 30);
button2.setBounds(95, 70, 70, 30);
button3.setBounds(170, 70, 70, 30);
add(button1);
add(button2);
add(button3);
    l1=new List(7);
l1.add("Monday");
l1.add("Tuesday");
l1.add("Wednesday");
l1.add("Thursday");
l1.add("Friday");
l1.add("Saturday");
l1.add("Sunday");
l1.setBounds(250, 50, 100, 60);
add(l1); c1=new Checkbox("Pick Me");
c1.setBounds(360, 60, 60, 50);
add(c1);
l=new Label("Enter Name Here");
l.setBounds(420, 60, 100, 50);
add(l);
t1=new TextField();
t1.setBounds(505, 70, 200, 30);
add(t1);
setTitle("Flowlayout");
setSize(730,150);
setLayout(null);
setVisible(true);
}
public static void main(String[] args) {
new awtsecond();
}

}


Output:

Fourth week Term Work Program 2

2) Write a Java Program that creates a SWING 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 SWING Frame
d. Add a button named “Cancel” to the window
e. On pressing “X” button, the window should hide


Program:
import java.awt.Frame;
import javax.swing.*;
public class swingfirst {
public static void main(String[] args) {
JFrame frame=new JFrame("My First Swing Frame");
frame.setSize(500, 400);
frame.setLocation(150, 150);
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
JButton button=new JButton("Cancel");
frame.getContentPane().add(button);
frame.setVisible(true);
}

}
Output:


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