I want to create a JFrame and add panel to it ,the problem in drawing line in this panel
package panel;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Main {
public static void main(String[] args) {
JFrame window = new JFrame();
window.setSize(200, 200);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Graphics g =null ;
g.drawLine(50, 50, 20, 25);
JPanel panel = new JPanel();
panel.paintComponents(g);
window.add(panel);
window.setVisible(true);
}
}