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 2
February 17, 2019FOURTH WEEK LAB PROGRAM, Fourth Week Term Work, SDM JAVA LAB TERM WORK, SwingNo comments
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
February 17, 2019Awt, FOURTH WEEK LAB PROGRAM, Fourth Week Term Work, SDM JAVA LAB TERM WORKNo comments









