Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Tim Cooke
Devaka Cooray
Sheriffs:
Liutauras Vilda
paul wheaton
Rob Spoor
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Piet Souris
Mikalai Zaikin
Bartenders:
Carey Brown
Roland Mueller
Forum:
Beginning Java
Icons
Karen Baog
Ranch Hand
Posts: 120
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi all,
Trying to learn putting icons on buttons.
The icon shows when I run it, but the description is not shown.
Am I missing something?
JPanel panel = new JPanel(); ImageIcon icon = new ImageIcon("c:/images/image1.gif", "Image"); JButton button = new JButton(icon); panel.add(button);
amerzil co-ed student<br />"Praise be the Code"
James Carman
Ranch Hand
Posts: 580
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What description? You haven't told the JButton which text you want it to display.
James Carman, President<br />Carman Consulting, Inc.
Karen Baog
Ranch Hand
Posts: 120
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi James,
How do I add an icon and a description to the button?
I'm playing with the ImageIcon, thinking that the second argument will provide the description. I think I'm wrong here. Now, I don't know what to do.
amerzil co-ed student<br />"Praise be the Code"
Karen Baog
Ranch Hand
Posts: 120
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I figured it out.
Thanks.
amerzil co-ed student<br />"Praise be the Code"
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Image as a button
jbutton background image
Image inside jar file
Problems with ImageIcon in JButton
running a class a particular number of times
More...