Skip to content

Commit

Permalink
GP-4621 fix tooltip hover of dialog status message when html
Browse files Browse the repository at this point in the history
  • Loading branch information
dev747368 committed May 22, 2024
1 parent 982dc01 commit 573d60b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -800,15 +800,10 @@ private void clearProgress() {
* If the status message fits then there is no tool tip.
*/
private void updateStatusToolTip() {
String text = statusLabel.getText();
// Get the width of the message.
FontMetrics fm = statusLabel.getFontMetrics(statusLabel.getFont());
int messageWidth = 0;
if ((fm != null) && (text != null)) {
messageWidth = fm.stringWidth(text);
}
if (messageWidth > statusLabel.getWidth()) {
statusLabel.setToolTipText(text);
Dimension preferredSize = statusLabel.getPreferredSize();
Dimension size = statusLabel.getSize();
if (preferredSize.width > size.width || preferredSize.height > size.height) {
statusLabel.setToolTipText(statusLabel.getOriginalText());
}
else {
statusLabel.setToolTipText(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ public void setText(String text) {
updateHtmlView();
}

/**
* Returns the original text of the label.
* <p>
* The {@link #getText()} method for this class can return a value that is missing the leading
* &lt;html&gt; tag.
*
* @return text of this label
*/
public String getOriginalText() {
return isHtml ? HTML_TAG + getText() : getText();
}

@Override
public void updateUI() {
super.updateUI();
Expand Down

0 comments on commit 573d60b

Please sign in to comment.