• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rectangle doesn't show in GUI

 
John Joe
Ranch Hand
Posts: 68
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added a rectangle in GUI, but it doesn't shown. Anything I missed?




Capture.PNG
[Thumbnail for Capture.PNG]
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Don't use a null layout. Swing was designed to be used with layout managers.
2. Don't use static variables
3. Don't override setVisible()
4. Your class doesn't use I/O so there is no need to handle the IOException

Read the section from the Swing tutorial on Custom Painting for a working example that shows the proper way to do painting in Swing.

As you can see you have many problems so start with the working example code and modify it for your requirements so you have a better structured class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!