I'm guessing this is some homework assignment?
A couple things I'm assuming from your response.
1) All ovals have the same height and width of the rectangle.
2) An oval may not be drawn inside the rectangle as the lines would touch.
First off there are inputs which make solving the puzzle impossible, something to think about. Second given the parameters in most cases the ovals can/will occupy the same space as if they were rectangles. It will only be as space gets tight that it may be worthwhile to place ovals in positions where the 'corners' would overlap.
You should be able to use a 'greedy' algorithm to make this work. That is what looks best at the current time, just do, and assume the later ones will take care of themselves.
So what I would do might look something like this.
Create some class that will keep track of used space and for allocating space for the next object. It could look something like this. (I'm just putting the method signatures)
As you already seem to understand the screen is basically a 2D array of pixels. You can simulate that inside the SpaceAllocator with a 2D array of booleans (on/off) or something similar. If you used this it would go something like:
-Get the input from the user.
-Check for out of bounds.
-call placeShape to place the rectangle.
-call allocateShape once for each oval.
-if and exception is thrown report to the user it is impossible.
-call drawShapes with the Graphics context from the applets paint method.
(forgive if I'm a bit off on the Graphics in the applet bit, been awhile)
The placeShape and draw shapes are fairly self explanitory.
The allocateShape could do something like this:
-Start at the top left of your 2D array and look for an opening.
-Each time you find one check if the new shape will fit.
-Once you find a place you would actually create a shape with the correct location and store it.
-Flip the locations on the 2D array to used (either true or false, true might be easier as false is the default)
The algorithm used to see if a shape will fit and the algorithm used to flip the 2D array will determine how effective the program will be. To begin with I would simply get the bounding rect of each shape and use that to see if a shape will fit. On the flip I would flip all 'points' within the bounding rect (a fill, not just the outline).