I cannot draw a line in a panel. Every time i tried it shows a blank white window and i can't figure out what's wrong. I'm really sorry if the my problem has a simple solution and that i have wasted your time. (if something isn't understandable i will try to explain it better | English isn't my native language)
Code:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class AU19d extends JPanel {
protected void paintComponent(Graphics g){
super.paintComponent(g);
g.setColor(Color.RED);
g.drawLine(10, 10, 110, 110);
}
public static void main(String[] args) {
JFrame f = new JFrame("AU19d");
JPanel p = new JPanel();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p.setPreferredSize(new Dimension(200,50));
p.add(new AU19d());
f.add(p);
f.pack();
f.setVisible(true);
}
}