Drawing a JComponent inside a JPanel
I am trying to display a JComponent inside a JPanel. I am using null layout because location of the components can be changed during runtime and I have to control them. But the following code does not work. The JComponent only becomes visible on display if I explicity call the "paintComponent" method, which I think is not good practice. My JComponent Class public class MyIcon extends JComponent { private double xPos; private double yPos; private double radius = 30; public MyIcon(double xPos, double yPos) { this.xPos = xPos; this.yPos = yPos; this.setBounds((int)xPos, (int)yPos, (int)radius,