So start reading the API documentation for the ImageIcon class. There must be
a way to figure out whether or not the icon was really loaded. One of the methods
should be able to give you the answer.
So start reading the API documentation for the ImageIcon class. There must be
a way to figure out whether or not the icon was really loaded. One of the methods
should be able to give you the answer.
I'M TRYING TO WRITE A CODE ON VENDING MACHINE. BUT FIRST OF ALL I NEED TO PUT PICTURES ON THE BUTTONS THAT I'M USING.
THE ThING IS I'M HAVING ERRORS WHEN USING THE SETICON. this is my code below....... (i jus want to put pictures on button before i proceed with the code.)
chip.SetIcon(ne w ImageIcon("chip s1.gif"));
mintGum.SetIcon (new ImageIcon("mint Gum.gif"));
nacho.SetIcon(n ew ImageIcon("nach os.gif"));
cookie.SetIcon( new ImageIcon("cook ies.gif"));
lifesaver.SetIc on(new ImageIcon("life saver.gif"));
mandm.SetIcon(n ew ImageIcon("m_m. gif"));
walnut.SetIcon( new ImageIcon("waln ut.gif"));
popcorn.SetIcon (new ImageIcon("popc orn.gif"));
mixednut.SetIco n(new ImageIcon("mixf ruit.gif"));
// g.drawImage(chi ps, 20, 20, this);
}
}
HI...you should set the images to button before adding the button objects into panel...and images must be placed in same folder in which your application is going to develop...other you must give full path of "* .gif " file to set imageIcon...you can use JButton instead of simple button object if u are aware about JApplet it'll more helpfull for u to create a windows application..ho pe best for success
Comment