Demo: fixed exception if hint is shown and switching to a non-FlatLaf L&F

This commit is contained in:
Karl Tauber
2021-11-12 11:39:33 +01:00
parent 0cb50355b7
commit 77582be7fd

View File

@@ -21,6 +21,8 @@ import java.awt.event.MouseAdapter;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import javax.swing.border.LineBorder;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.ui.FlatDropShadowBorder;
import com.formdev.flatlaf.ui.FlatPopupMenuBorder;
import com.formdev.flatlaf.ui.FlatUIUtils;
@@ -98,8 +100,14 @@ class HintManager
public void updateUI() {
super.updateUI();
if( UIManager.getLookAndFeel() instanceof FlatLaf ) {
setBackground( UIManager.getColor( "HintPanel.backgroundColor" ) );
setBorder( new FlatPopupMenuBorder() );
} else {
// using nonUIResource() because otherwise Nimbus does not fill the background
setBackground( FlatUIUtils.nonUIResource( UIManager.getColor( "info" ) ) );
setBorder( new LineBorder( Color.gray ) );
}
}
void showHint() {
@@ -115,10 +123,12 @@ class HintManager
public void updateUI() {
super.updateUI();
if( UIManager.getLookAndFeel() instanceof FlatLaf ) {
setBorder( new FlatDropShadowBorder(
UIManager.getColor( "Popup.dropShadowColor" ),
UIManager.getInsets( "Popup.dropShadowInsets" ),
FlatUIUtils.getUIFloat( "Popup.dropShadowOpacity", 0.5f ) ) );
}
// use invokeLater because at this time the UI delegates
// of child components are not yet updated