Reputation: 33
Below is code I received directly from my teacher but it outputs nothing! all I see is a blank window open and nothing is displayed in it. I can not understand why please help!
import java.awt.*;
import javax.swing.*;
public class IntroToGraphics extends JFrame
{
/**
*
*/
public IntroToGraphics() {
// TODO Auto-generated constructor stub
super("howdy");
setSize(1500,850);
setVisible(true);
}
public void Paint(Graphics g) {
g.drawString("Hello World",1000,450);
g.fillRect(200,200,50,50);
}
public static void main (String[]args) {
new IntroToGraphics();
}
}
If anything isn't clear please let me know and I will fix it promptly.
Upvotes: 1
Views: 54
Reputation: 368
The method Paint
name should be paint
. In addition, it is better to use @Override
annotation since you have overridden the paint method.
The Output will be
Upvotes: 1