The frame is displayed empty,, so how to make the Rectangle object visible
package rectang; import javax.swing.*; import java.awt.*; import java.awt.Graphics.*; public class RectAn extends JFrame { public void paint(Graphics g) { super.paint(g); Rectangle r1 = new Rectangle(); //Here is the object I mean. r1.setBounds(20, 20, 40, 50); //Setting its bounds. } public RectAn(String title) { super(title); this.setSize(400, 400); setDefaultCloseOperation(EXIT_ON_CLOSE); } }
Main method
package rectang; public class RectanG { public static void main(String[] args) { RectAn r = new RectAn("Rectangle"); r.setVisible(true); } }