Creating a Window Using JFrame in Java

Here's an example of a simple window in java:

Java JFrame Window (JFrame size - 300x280)
Here's the code:


import javax.swing.JFrame;

public class MyClass extends JFrame{
   
    public MyClass(){
        setSize(800,600);
        setTitle("JavaJFrameWindow1");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
    }
   
    public static void main(String[] args){
        new MyClass();
    }
} 



 You can modify the window by adding or changing the JFrame's attributes in the constructor.


0 comments:

Post a Comment