如题,小弟界面需要这个,请诸位前辈指教,有人解决立刻给分,要源代码。

解决方案 »

  1.   

    package program;import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Shape;
    import java.awt.geom.RoundRectangle2D;
    import javax.swing.JButton;public class MyButton extends JButton {
        private Shape shape = null;
        public int width,height;    public MyButton(String text) {
         super(text);
            Dimension size = getPreferredSize();
            setPreferredSize(size);
            width=height=size.width = size.height =65;
            shape = new RoundRectangle2D.Float(0, 0, width-5, height-15, 25, 25);
            setContentAreaFilled(false);
        }protected void paintComponent(Graphics g){
        Graphics2D g2d = (Graphics2D) g;
        if (getModel().isArmed()) {
           g2d.setColor(Color.blue);
           
       } else {
       g2d.setColor(Color.black);
       }
        g2d.draw( shape);
        super.paintComponent(g2d);
      }protected void paintBorder(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.draw(shape);
       }public boolean contains(int x, int y) {
    return shape.contains(x, y);

            }
        }在你的程序中生成MyButton的实例,看看是不是你要的
      

  2.   

    呵呵,楼上给的是按钮,我需要list形势的,谢谢
      

  3.   

    就是一个圆角矩形那种形状的jlist,其他和普通的list没有区别,这个list的标题在控件的左上,字体稍大。list背景用一种颜色填充,就像一个单一颜色的圆角矩形一样。