fork download
  1. import javax.swing.*;
  2. public class FirstSwingExample {
  3. public static void main(String[] args) {
  4. JFrame f=new JFrame();//creating instance of JFrame
  5.  
  6. JButton b=new JButton("click");//creating instance of JButton
  7. b.setBounds(130,100,100, 40);//x axis, y axis, width, height
  8.  
  9. f.add(b);//adding button in JFrame
  10.  
  11. f.setSize(400,500);//400 width and 500 height
  12. f.setLayout(null);//using no layout managers
  13. f.setVisible(true);//making the frame visible
  14. }
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:2: error: class FirstSwingExample is public, should be declared in a file named FirstSwingExample.java
public class FirstSwingExample {  
       ^
1 error
stdout
Standard output is empty