create jframe java code example
Example 1: java simple jframe example
import javax.swing.*;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.*;
public class JFrameExample{
public static void main(String[] args){
// Create frame with title Registration Demo
JFrame frame= new JFrame();
frame.setTitle("JFrame Demo");
frame.pack();
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Example 2: 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
}
}