Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  grbuttonx.java
Language: JAVA
Code:
package grlib1;
import javax.swing.JButton;
import java.awt.*;
import java.io.Serializable;


/**
 * @author [email protected]
 */
public class grbuttonx extends JButton implements Serializable {
    private Image img;
    public grbuttonx() {
        img=null;
    }
    
    public void setImage(Image i) {
        img=i;
    }
    
     public void paint(Graphics g) {
        if (img != null)
            g.drawImage(img, 0, 0,null);
        else {
            g.setColor(Color.red);
            Dimension size = getSize();
            g.fillOval(0, 0, size.width, size.height);
            }
    }

}
Comments: