0

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

enter image description here

Nitesh Verma
  • 1,795
  • 4
  • 27
  • 46
zerone
  • 105
  • 1
  • 3
  • 10

3 Answers3

2
JTextField textField = new JTextField() {  
            protected void paintComponent(Graphics g) {  
                super.paintComponent(g);  
                int y = (getHeight() - image.getHeight())/2;  
                g.drawImage(image, x0, y, this);  
            }  
        };  
Nambi
  • 11,944
  • 3
  • 37
  • 49
1

Build a custom component.

Take a look at http://gmigdos.wordpress.com/2010/03/30/java-a-custom-jtextfield-for-searching/

René Link
  • 48,224
  • 13
  • 108
  • 140
  • While link only answers are allowed it is good idea to provide main content to answer in case link will change. – Pshemo Sep 11 '13 at 09:59
0

Read this tutorial. He does exactly what you're trying to do: http://harryjoy.me/2012/07/14/jtextfield-with-image-inside-it/

Harry Joy
  • 58,650
  • 30
  • 162
  • 207
cutmancometh
  • 1,677
  • 3
  • 20
  • 28