-1

I am trying to add image in a button this ImageIcon is giving me error, I also import java.awt.Image;. But still image is not uploading, what can I do now?

JButton btnFind = new JButton("Find");
    Image img = new ImageIcon(this.getClass().getResource("/search.png")).getImage();
    btnFind.setIcon(new ImageIcon(img)); 
    btnFind.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
        }
    });
    btnFind.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent arg0) {
            try {
                 cDriver.fObjectWithDataCity_V3(textFieldSearch.getText());
                 fDataInTextBoxes();



                } catch (Exception ee) {
                    // TODO Auto-generated catch block
                    ee.printStackTrace();
                }
Madhawa Priyashantha
  • 9,633
  • 7
  • 33
  • 60
Ahmed Abbas
  • 63
  • 1
  • 12

1 Answers1

0

you also need to import

import javax.swing.ImageIcon;
Madhawa Priyashantha
  • 9,633
  • 7
  • 33
  • 60