fork download
  1. package com.company;
  2. import javax.swing.*;
  3. import java.awt.*;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6.  
  7. public class SimpleGUI implements ActionListener {
  8. JButton button;
  9. public void go() {
  10. JFrame frame = new JFrame();
  11. JButton button = new JButton("click me");
  12. button.addActionListener(this);
  13. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  14. frame.getContentPane().add(button);
  15. frame.setSize(300, 300);
  16. frame.setVisible(true);
  17. }
  18. public void actionPerformed(ActionEvent event){
  19. button.setText("I've been clicked");
  20. }
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:7: error: class SimpleGUI is public, should be declared in a file named SimpleGUI.java
public class SimpleGUI implements ActionListener {
       ^
1 error
stdout
Standard output is empty