New Code
package test;
import javax.swing.*;
import java.awt.*;
public class TestWindow extends JFrame{
//------------------------------------------------------------------------------
public static void main(String[] args) {
new TestWindow();
}
//------------------------------------------------------------------------------
public TestWindow(){
setSize(300,300);
this.setUndecorated(true);
add(new Background());
setVisible(true);
}
//------------------------------------------------------------------------------
private class Background extends JPanel{
public Background(){
add(b);
repaint();
}
//------------------------------------------------------------------------------
Bubble b = new Bubble();
@Override
public void paintComponent(Graphics g){
super.paintComponent(g);
Color c = Color.cyan;
g.setColor(c);
g.fillRect(0, 0,getWidth(), getHeight());
}
//------------------------------------------------------------------------------
private class Bubble extends JPanel{
@Override
public void paintComponent(Graphics g){
super.paintComponent(g);
g.setColor(Color.green);
g.drawOval(0, 0, Background.this.getWidth(), Background.this.getHeight());
}
}
//------------------------------------------------------------------------------
}
}
Output

Problem
The aim is to draw a cyan window with a green circle on it. Later I will add components to the green circle so it will look like there is a window with a cyan background and a green circle with components in it.
The output however is only the cyan background. No circle.
I tried setting XOR mode to cyan but that did not work either. Am I nesting the classes wrong?
The major problem is here…
Not only are adding components to your container within you paint method, you’re also calling repaint, all this is going to conspire against you.
Paint is called by the repaint manager when ever your component needs to be updated, for all sorts of reasons. You should never call any methods that might invalidate it otherwise require the component to repainted, doing so will send you down slippery slope of CPU burn out.
Instead.
Bubblecomponent inside the constructor of theBackgroundcomponentgetPreferredSizemethods of both these components and provide useful hints so the layout managers have some idea of how much space the components might actually like to useThe major problem you are facing (other then the bad painting) is that the components are reporting themselves as requiring no height or width, meaning when the layout managers come to lay them out, they are effectively invisible
Update
I would recommend that you have a look at
Easter Egg
For taking advice and making an effort, let me give you a little help…
What I suggest you do is read through the code, go back to the Java Docs and tutorials and try and figure out what is going on 😉