Reputation: 550
Set an icon for a JFrame when it is minimized to the dock like other mac application.
Please help..
Upvotes: 3
Views: 636
Reputation: 12680
You're really talking about two things.
The icon of the application in the dock, in Finder, etc.
appbundler or even simply hand-creating the bundle is the solution to that, as already mentioned.
The icon of the application when minimised to the dock
When you minimise the application it becomes a separate dock entry which does not necessarily look like the application one.
The Window has setIconImages
- if you set this method, the application will become
that icon when minimised which will not look native. So you should check if you're
running on OSX before calling that method and avoid calling it.
By leaving out the call, you get the default behaviour where the minimised icon will be a miniature copy of what the window itself looks like, which is what we see other applications doing. It would be nice if the JRE would take care of that for us and just ignore the icons when running on Mac OS X.
Upvotes: 0
Reputation: 168825
An e.g. of what Mikle was referring to:
Now moved to: Sizes of frame icons used in Swing.
Upvotes: 1
Reputation: 258
Use the jar bundler that is available with Mac os to create an App. Set the icon of the app using jar bundler and dont set any icons for your jframe.
Upvotes: 0
Reputation: 10153
Window class has method setIconImages
which requires java.util.List<? extends Image>
as an argument. You will have to pass a list of images with different sizes so that OS can choose one from that list for each specific situation - would it be minimized icon, icon for dock/toolbar, icon for window or icon for any other system-specific UI element.
I usually pass a lot of images for my own application in different sizes: 16x16, 24x24, 32x32, 48x48, 64x64, 128x128, 256x256, 512x512
The large ones are usually used by large toolbars or by folder view to display icons for files associated with your application. Also usually 16x16 icon is used as window (frame/dialog) icon. Other icons can be used in a lot of different situations which depends on what OS you have (Windows, Mac OS e.t.c).
Upvotes: 0