jQuery in Action, 2nd edition*
The moose likes Swing / AWT / SWT and the fly likes Not drawing the Button? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Not drawing the Button?" Watch "Not drawing the Button?" New topic
Author

Not drawing the Button?

Jing Liang
Ranch Hand

Joined: Oct 23, 2006
Posts: 40
My codes able to draw the ellipse but not the button("Start"). I added the button to the JComponent. Could someone tell me what I did wrong and help me out? Thanks in advance

Eric Daly
Ranch Hand

Joined: Jul 11, 2006
Posts: 143
I'm still a noob when it comes to swing, but I noticed you're trying to add your button to the PaintSurface. I would think you should make the button on top of the pane but not inside PaintSurface. So you could add the button during init(). Or else maybe you're just drawing your entire ellipse over the button, so you never see it. And you don't have any actionlisteners yet, so you can't test to see if the button works anyhow.


Studying for SCJP 6
Jing Liang
Ranch Hand

Joined: Oct 23, 2006
Posts: 40
It works. Thanks Eric
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
If you add super.paint(g) as the first line of the paint method, does it work?
Eric Daly
Ranch Hand

Joined: Jul 11, 2006
Posts: 143
Keith, I tried your suggestion, but the button still did not show up. I wonder what you could do to actually get the button to appear...
Jing Liang
Ranch Hand

Joined: Oct 23, 2006
Posts: 40
The button shows up when I add the button at the init() BorderLayout.NORTH
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not drawing the Button?
 
Similar Threads
Not to show the ellipse?
: A gray color box appeare d when loading an image on JPanel
Adding a sound file to a java applet
Not able to change Background color of a component
First time with applets