Re: newbie:this program gives error on compiling
Boris wrote:
This program gives 2 errors on compiling.
This SSCCE compiles and runs, but..
<sscce>
import java.awt.*;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import javax.swing.*;
public class OvalButton extends JButton {
public OvalButton(String text){
super(text);
setOpaque(false);
}
public Shape getShape(){
return new Ellipse2D.Float(
0f,
0f,
(float)(getWidth()/2),
(float)(getHeight()));
}
public void paint(Graphics g){
Graphics2D g2=(Graphics2D) g;
g2.setClip(getShape());
super.paint(g2);
}
public boolean contains(int x,int y){
return getShape().contains(x,y);
}
public static void main(String[] args) {
JOptionPane.showMessageDialog(
null,
new OvalButton("Hi!"));
}
}
<sscce>
Please help , I am not able to understand the problem.
..it is the least of the problems with this code, this
approach, and the wasted screen acreage of 'oval
shaped' buttons in general.
--
Andrew Thompson
http://www.physci.org/
Message posted via http://www.javakb.com