hello please help me i have picture then i want to put on my JButton but the problem is that my picture is too big its jpg file how to make this bmp file so that it fit to my Jbutton..hoping for your positive responds
jemz
-1
Master Poster
Recommended Answers
Jump to PostThe JButton takes as argument an Icon.
If you look at the class ImageIcon which extends Icon you will find 2 things:
The constructor of ImageIcon takes as argument an Image object.
There is a method: getImage() that "Returns this icon's Image."The Image class has the method that …
Jump to PostCreate the image object from the file, then create an ImageIcon frmo it and the set the button's icon with that icon.
Image myImage = getToolkit().createImage("myImage.jpg"); ImageIcon myIcon = new ImageIcon(myImage); myButton.setIcon(myIcon);//here you set the icon for your button
All 6 Replies
javaAddict
900
Nearly a Senior Poster
Team Colleague
Featured Poster
jemz
-1
Master Poster
Clawsy
1
Posting Whiz in Training
javaAddict
900
Nearly a Senior Poster
Team Colleague
Featured Poster
Clawsy
1
Posting Whiz in Training
jemz
-1
Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.