Is there a way to control the size of a title icon? For example, can I supply a large icon but have it always render at 16x16 in docking frame tabs?
I want to do this because the title icon becomes the window icon when a frame is floating. Some alt-tab window switchers display the window icon. If I use a 16x16 icon, it’s upscaled and blurry in the window switcher. If I use a large icon, it’s rendered at full size in the docking frame tab. (Using Eclipse theme.)
… but… you can modify the window that shows the icons, and replace it with a custom frame that shows larger icons. I admit, this is not the most beatiful code, but it should work:
I don’t want DF to show large icons. I want small icons in the tabs and menus. I’m looking for a way to supply a large icon but have DF render it small. The only place it would be displayed large is in the OS window switcher.
If this capability doesn’t exist, I guess I will have to extend SingleCDockableListMenuPiece and whatever class draws the icons in tabs.
*** Edit ***
I achieved partial success with this:
// these inline extensions give the menu icons a consistent size
final SingleCDockableListMenuPiece piece = new SingleCDockableListMenuPiece(dockControl) {
@Override
protected Item create(final Dockable dockable) {
return new Item(dockable) {
private static final long serialVersionUID = 1L;
{
Icon icon = dockable.getTitleIcon();
if(icon instanceof ImageIcon) {
Image image = ((ImageIcon) icon).getImage();
// TODO can the preferred size be obtained from the look & feel?
Image scaled = image.getScaledInstance(16, 16, java.awt.Image.SCALE_SMOOTH);
ImageIcon scaledIcon = new ImageIcon(scaled);
setIcon(scaledIcon);
}
}
};
}
};
This does what I wanted for the menu icons. But I noticed that my main goal may not be achievable. It seems that Java always supplies a scaled-down icon to the OS for use in the window switcher. This is not only true of the title icons of dockables, but the icon of my app’s main JFrame as well. I’ll have to solve that before there’s any point to what I was trying to do with the title icons.
And I must say I do not fully understand your problem. The only times DockingFrames shows some Icons on a JFrame is for floating Dockables and those Icons can be changed by the workaround/hack I provided earlier. So either I am not picking up a vital clue, or we are not speaking of the same frames. I need some more explanations to help you.