Home>

I am working on a program to draw a circle by inputting radius and color using 3 subclasses and 1 main class in Java.
The following problems cannot be solved by any means, and I am in trouble.
Thank you.

The error that is occurring

Main.java:14: error: illegal start of expression
      public void setRadius(int sr)
      ^
Main.java:14: error: illegal start of expression
      public void setRadius(int sr)
             ^
Main.java:14: error:';' expected
      public void setRadius(int sr)
                           ^
Main.java:14: error:';' expected
      public void setRadius(int sr)
                                  ^
Main.java:19: error: illegal start of expression
      public void setRGB(int c)
      ^
Main.java:19: error: illegal start of expression
      public void setRGB(int c)
             ^
Main.java:19: error:';' expected
      public void setRGB(int c)
                        ^
Main.java:19: error:';' expected
      public void setRGB(int c)
                              ^
Main.java:24: error: illegal start of expression
      public void setRadiusAndRGB(int sr, int c)
      ^
Main.java:24: error: illegal start of expression
      public void setRadiusAndRGB(int sr, int c)
             ^
Main.java:24: error:';' expected
      public void setRadiusAndRGB(int sr, int c)
                                 ^
Main.java:24: error:<identifier>expected
      public void setRadiusAndRGB(int sr, int c)
                                         ^
Main.java:24: error: not a statement
      public void setRadiusAndRGB(int sr, int c)
                                              ^
Main.java:24: error:';' expected
      public void setRadiusAndRGB(int sr, int c)
                                               ^
Main.java:30: error: illegal start of expression
      public void paintComponent(Graphics g)
      ^
Main.java:30: error: illegal start of expressionpublic void paintComponent(Graphics g)
             ^
Main.java:30: error:';' expected
      public void paintComponent(Graphics g)
                                ^
Main.java:30: error:';' expected
      public void paintComponent(Graphics g)
                                           ^
18 errors
Main.java:14: error: illegal start of expression
      public void setRadius(int sr)
      ^
Main.java:14: error: illegal start of expression
      public void setRadius(int sr)
             ^
Main.java:14: error:';' expected
      public void setRadius(int sr)
                           ^
Main.java:14: error:';' expected
      public void setRadius(int sr)
                                  ^
Main.java:19: error: illegal start of expression
      public void serRGB(int c)
      ^
Main.java:19: error: illegal start of expression
      public void serRGB(int c)
             ^
Main.java:19: error:';' expected
      public void serRGB(int c)
                        ^
Main.java:19: error:';' expected
      public void serRGB(int c)
                              ^
Main.java:24: error: illegal start of expression
      public void serRadiusAndRGB(int sr, int c)
      ^
Main.java:24: error: illegal start of expression
      public void serRadiusAndRGB(int sr, int c)
             ^
Main.java:24: error:';' expected
      public void serRadiusAndRGB(int sr, int c)
                                 ^
Main.java:24: error:<identifier>expected
      public void serRadiusAndRGB(int sr, int c)
                                         ^
Main.java:24: error: not a statement
      public void serRadiusAndRGB(int sr, int c)
                                              ^
Main.java:24: error:';' expected
      public void serRadiusAndRGB(int sr, int c)^
Main.java:30: error: illegal start of expression
      public void paintComponent(Graphics g)
      ^
Main.java:30: error: illegal start of expression
      public void paintComponent(Graphics g)
             ^
Main.java:30: error:';' expected
      public void paintComponent(Graphics g)
                                ^
Main.java:30: error:';' expected
      public void paintComponent(Graphics g)
                                           ^
18 errors
Applicable source code
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class PanelCircle extends JPanel
{// class
   private int radius;
   private int rgb;
   public PanelCircle()
   {
      public void setRadius(int sr)
      {
         radius = sr;
      }
      public void serRGB(int c)
      {
         rgb = c;
      }
      public void serRadiusAndRGB(int sr, int c)
      {
         radius = sr;
         rgb = c;
      }
      public void paintComponent(Graphics g)
      {
         g.setColor(rgb);
         g.fillOval(10,10,radius*2,radius*2);
      }
   }
} // end class
What I tried

I'm using it after copying it from the code I wrote before, but I get an error.
I've copied it many times and reviewed the previous code, but I'm not sure.

Supplementary information (FW/tool ​​version, etc.)

Please provide more detailed information here.