Search code examples
javabuttonbluej

Invalid Method Declaration? Return Type Required?


import java.util.*;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
//----------I could just do import java.awt.*; and import java.swing.*; but, when the program get larger, this could cause glitches, so it's better not to----------
public class Gui extends JFrame{

public class QA //THIS IS WHERE I'M GETTING THE ERROR MESSAGE
{
    private int x;
         private JButton reg;
         private JButton custon;

         public Gui();
    public QA()
    {

I coppied code from a youtube video (https://www.youtube.com/watch?v=6iV-v_m0z0w), but I'm not sure what the problem is. Appreciate any help :)


Solution

  • public Gui(); doesn't have any return type and doesn't have any implementation and it shouldn't be inside QA

    move this constructor method up to Gui class

    public class Gui extends JFrame{
    
    public Gui(){}
    
    public class QA //THIS IS WHERE I'M GETTING THE ERROR MESSAGE
    {
    ...
    }