I\'m trying to create a program that draws shapes (a rectangle on the example below) using JPanel\'s paintComponent(), but I can\'t get it to work and can\'t spot what is wr
Your class DrawPanel is confined to the scope of your main method and is not visible to your constructor.
DrawPanel
main
You need to move DrawPanel out of your main method, then add it to your JFrame:
JFrame
frame.add(panel);
Also, better to call frame.setVisible(true) after all components have been added.
frame.setVisible(true)