I cannot see why the paintComponent is not being executed. The switch...case is inside this method. Not sure what the default case should be? I have the three different shapes that need to be drawn....
Type: Posts; User: sjdganc
I cannot see why the paintComponent is not being executed. The switch...case is inside this method. Not sure what the default case should be? I have the three different shapes that need to be drawn....
So you're able to see the shapes generate? The code compiles for me as well but I only get an orange window.
I moved setVisible() to after everything as you suggested but still get the same errors as most recently stated above. I also see your points about the for loop so I commented those out for now and...
I thought
public Draw() {
}
is the no-arg constructor. But I see I don't have it doing anything, so I added:
public Draw() {
When I comment these three lines out I get the orange box but still no shapes. In other examples I have seen where the for loop should be in the main method. Is this part of my problem or am I...
I put that back in in the Draw class and it compiles with no errors. But still get the same above errors:
import javax.swing.*;
import java.awt.*;
import java.util.Random;
public class...
Ok, I see that. Thank you. So the Draw program new code compiles without error but I get a new error in the ShapeGen program.
import javax.swing.*;
import java.awt.*;
import java.util.Random;...
I'm trying to get this but I'm not quite understanding. So I changed the name of the draw program to Draw and left the constructor as public draw. I get this error on the Draw program
import...
I tried it and see from the tutorial you provided that it is a no-arg constructor, so I'm not telling it what I want to do, right? But in the ShapeGen program I get this error:
ShapeGen.java:32:...
I'm not sure what you mean by constructor. In the draw program do I change it to this
public draw() {
}
This code is supposed to run the shapes in the draw program. I added a draw object to the ShapeGen code but get the below errors:
ShapeGen.java:29: error: constructor draw in class draw cannot be...
Do I need that in the draw program? I changed it to the below code. I get just a yellow window to display, but no shapes.
import javax.swing.*;
import java.awt.*;
import java.util.Random;
...
No, I had it outside of the brackets. Thank you for pointing that out. When I fixed that I realized the third error expecting the } so I fixed that. Now I am getting this error:
ShapeGen.java:13:...
Ok, thank you. I have some code commented out in the main program so that I did not lose what I had working at one point.
import javax.swing.*;
import java.awt.*;
import java.util.Random;
...
I am trying to get random shapes to generate automatically. I was able to get just three shapes to generate but nothing random. When I added the random code now only the frame shows up and no shapes....