Can you tell me how to do like below in JAVA SWING.

JTextField textField = new JTextField() {
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int y = (getHeight() - image.getHeight())/2;
g.drawImage(image, x0, y, this);
}
};
阅读本教程。他做你想做的事:http: //harryjoy.me/2012/07/14/jtextfield-with-image-inside-it/