Java compilation Error: no suitable constructor found for Box(int)

I spent a lot of time trying to figure out why my Java program was giving me a compilation error on the Box constructor that said Error: no suitable constructor found for Box(int). My attempt was to simply use the Box class in the Swing Library. I figured out why.

It so happens that in the same source code directory, I also had a Box.java file that was written to calculate area of a Box. Whereas, my intent was to use the Swing library Box command for a GUI program I was writing, I figured that this was the possible reason for the “Error: no suitable constructor found for Box(int)”.

Big learning… every project in it’s own folder or make sure you use packages and do not create your own Box class in the folder where your program to call the Box class of Swing, is stored.