一般图标都是矩形的,怎么让图标和按钮大小一致。谢谢

解决方案 »

  1.   

    使用圆形图片的话可以
    jbutton.setContentAreaFilled(false);不然就得自己绘制了。
      

  2.   

    Sets the contentAreaFilled property. If true the button will paint the content area. If you wish to have a transparent button, such as an icon only button, for example, then you should set this to false. Do not call setOpaque(false). The default value for the the contentAreaFilled property is true.
    This function may cause the component's opaque property to change.The exact behavior of calling this function varies on a component-by-component and L&F-by-L&F basis.
      

  3.   

    问题是直接添加的图片是矩形的,不是圆形的啊!能不能用paintComponent或者drawImage什么的把图片画成圆形的呢?谢谢
      

  4.   

    这样,你还不如使用PhotoShop/Paint.net 之类的软件先把图片处理好。
      

  5.   

    Graphics 的   public abstract void setClip(java.awt.Shape);
    方法。
    你还需要重写 从 JComponent 继承的contains(int,int)