how to create jframe in java code example

Example 1: java create jframe

import javax.swing.JFrame;

public class example {
  public static void main(String[] args){
    JFrame frame = new JFrame();
    frame.setSize(100,100);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOES);
    frame.setTitle("Example Frame");
    frame.setVisible(true);
  }
}

Example 2: java create window

//THIS IS A FIX OF THE ONE BY FRANCY FROG
//THEY FIXED THEIRS
import javax.swing.JFrame;

public class example {
  public static void main(String[] args){
    JFrame frame = new JFrame();
    frame.setSize(100,100);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("Example Frame");
    frame.setVisible(true);
  }
}

Example 3: create jframe java

public JFrame frame = new JFrame();//creating jframe

Class main(){
public static void main(String[] args){
  frame.setSize(200,200); //setting size
  frame.setVisable(true); //sets visability 
  frame.setDefaultCloseOperation.(JFrame.EXIT_ON_CLOSE); //allow jframe to close when clicked

}
  }

Tags:

Java Example