Ask coding questions

← Back to all posts
1
Using JAVA AWT graphics
technomustang (0)

When introducing methods and method calls, we do a Smiley Face

I would like to figure out how to set up the files to allow code like this to run in Repl

public void smileyFace( Graphics window )
{
window.setColor(Color.WHITE);
window.fillRect(0,0,800,600);

  window.setColor(Color.BLUE);
  window.drawString("SMILEY FACE LAB ", 35, 35 );

  window.setColor(Color.YELLOW);
  window.fillOval(210,100,400,400);

  window.setColor(Color.GREEN);
  window.fillOval(275,220,60,40);

}

So far all I have seen is attempts that were unsuccessful. I have heard people have Jframe and GUI working but been unable to find a working example of being able to use the AWT draw and fill commands.