Cannot set tooltip to ComponentWithBrowseButton's button



My class extends ComponentWithBrowseButton and I need to set a tooltip text for the button. I use 

getButton().setToolTipText("My text");

But the method getButton is marked as Deprecated with forRemoval=true. So I look for a legal way to set the tooltip. The ComponentWithBrowseButton's constructor contains the code:

// FixedSizeButton isn't focusable but it should be selectable via keyboard.
if (ApplicationManager.getApplication() != null) { // avoid crash at design time
new MyDoClickAction(myBrowseButton).registerShortcut(myComponent);

Looks like it allows to customise tooltip through the overriding getIconTooltip, but registerShortcut sets own tooltip text anyway.

评论操作 固定链接

Hi Anton,

It seems that the class wasn’t designed to handle custom button tooltips, and there is no good solution for this.

I suggest using ExtendableTextComponent if it matches your use case, or creating an issue on with a proposal to add the tooltip customization possibility in ComponentWithBrowseButton.