Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using JButtons togheter with public void paint(Graphics g)

807606Feb 26 2007 — edited Feb 26 2007
I noticed that the JButton is not shown when in the class there is a public void paint(Graphics g)
You can then only see when you have your mouse over it...
can somebody tell me how the button can still be shown, even with a public void paint(Graphics g)?

here's the code:
/**
 * @(#)test.java
 *
 * test Applet application
 *
 * @H�ctor van den Boorn 
 * @version 1.00 2007/2/26
 */
 
import java.awt.*;
import java.applet.*;
import javax.swing.*;

public class test extends Applet
{

	JButton button;
	
	public void init() 
	{	
		setLayout(null);
		button = new JButton("Click here");
		button.setBounds(20,20,100,20);
		this.add(button);
	}

	public void paint(Graphics g)
	{
		g.drawString("Why isn't this working?",100,100);
	}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2007
Added on Feb 26 2007
9 comments
459 views