This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

About setting icon on JButton  RSS feed

 
Tony Chow
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Recently I have been working on an executable launcher. I tried to get the executable icons and set them on the JButtons. Still there are some problems.
Here is a part of the code:

Here the getConfig() method is already defined to get a string in a "properties" file.

However, the icons are very small and they don't fill the entire button.



How can the icon fill the entire button (for example, having a custom size of 48x48, or automatically filled the button)? The frame will not be resized.

Here is the whole code...


Please help...
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can the icon fill the entire button (for example, having a custom size of 48x48, or automatically filled the button)?


Well scaling up a small icon will cause pixilation so you are better to create larger icons.

Anyway, you should be able to use Darryl's Stretch Icon which will do scaling on the fly.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!