Hello I am new to the forum and hope you can help me I put my code and then the errors I receive thank you so much
import javax.swing.*; import java.awt.*; import javax.swing.Timer; public class Square extends JFrame { public Star() { setSize(1000,1000); setVisible(true); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args){ new Star(); } } class Doit extends JPanel { Timer timer; int x, y; public Doit() { setBackground(Color.RED); x = 30; y = 70; timer = new Timer(25, this); timer.start(); } public void paint(Graphics g) { g.drawRect(x, y, 500, 500); g.fillRect(x, y, 500, 500); } while(x<1000) { x++; repaint(); } }
Star.java:5: error: invalid method declaration; return type required public Star() { ^ Star.java:29: error: illegal start of type while(x<1000) { ^ Star.java:29: error: illegal start of type while(x<1000) { ^ Star.java:29: error: <identifier> expected while(x<1000) { ^ Star.java:29: error: ')' expected while(x<1000) { ^ Star.java:29: error: ';' expected while(x<1000) { ^ Star.java:30: error: illegal start of type x++; ^ Star.java:30: error: <identifier> expected x++; ^ Star.java:30: error: ';' expected x++; ^ Star.java:31: error: illegal start of type repaint(); ^ Star.java:31: error: <identifier> expected repaint(); ^ Star.java:33: error: class, interface, or enum expected }