项目里面弄的,就是简单的把JLabel的paintComponent重写一下,画个线
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JLabel;
/**
* 带下划线的label
* @author Administrator
*
*/
public class LineLabel extends JLabel{
public LineLabel(){
super();
}
public LineLabel(String str){
super(str);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int y = getHeight() - 1;
g.setColor(new Color(156,154,140));
g.drawLine(0, y, getWidth(), y);
}
}