Ask coding questions

← Back to all posts
It says i need an identifier to put in the parentheses but i don't know what identifier.
jascas03 (0)

import javax.swing.;
import java.awt.
;

class Main
{
public static void main(String[] agrs)
{
JFrame window = new JFrame("Jason's Canvas"); //title name
window.setSize(800, 600);//set the sixe of the window
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//the methood window.setDefaultCloseOperation is specifcally for the constant Jframe.EXIT_ON_CLOSE to close the application
window.setVisible(true);//Function window.setVisible. A function available to window-based terminal objects created via the window API, which toggles the visibility flag

}
void drawRectangles(Graphics)
{
Graphics2D g2d = (Graphics2D) g;
g2d.drawRect(30, 50, 420, 120);

}
}

Comments
hotnewtop
CSharpIsGud (924)

https://repl.it/@CSharpIsGud/JavaScript Here is a fixed version without any syntax errors, but it opens 2 windows one of them has a rectangle in it but it was hard to tell what in the world you were trying to do.
As my working version is almost entirely different from the original repl.

Vandesm14 (2636)

Could you put your code into a repl?

jascas03 (0)

@Vandesm14 I thought thats what i did and if i didnt how do i do that.

Vandesm14 (2636)

@jascas03 Oops, I didn't see that you did until now. My bad!

You need to remove the extra .'s right before the ; on lines 1 and 2

jascas03 (0)

@Vandesm14 i know but it says in line 40 that the word public is an illegal expression.

Vandesm14 (2636)

@jascas03 Not sure past that. I will get someone who knows Java better on this for you!

CSharpIsGud (924)

@jascas03 On line 39 you have an extra {

CSharpIsGud (924)

@jascas03 Also consider avoiding creating inner classes, as far as I can tell inner classes(a class defined in a class) may not have static properties.