JFrame

How to use JFrame in java

 Code : -- 

public class frame {
public static void main(String[] args) {
ImageIcon imageIcon=new ImageIcon("image2.jpeg");
JFrame jFrame=new JFrame(); // Calling Class
jFrame.setBounds(100,100,250,250);
//jFrame.setSize(250,250); // Set Size of JFrame
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // For Exit
jFrame.setLayout(null);
//jFrame.setResizable(false); // For Resize of JFrame
jFrame.setTitle("MyFrame"); // SEt Title
jFrame.setVisible(true); // For Showing
jFrame.setIconImage(imageIcon.getImage());

//JFrame is a top-level container that provides a window on the screen
//JFrame j =new JFrame();
//j.setSize(250,250);
//j.setVisible(true);
}
}

Comments