mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
Demo: fixed exception if hint is shown and switching to a non-FlatLaf L&F
This commit is contained in:
@@ -21,6 +21,8 @@ import java.awt.event.MouseAdapter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import javax.swing.border.LineBorder;
|
||||||
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
import com.formdev.flatlaf.ui.FlatDropShadowBorder;
|
import com.formdev.flatlaf.ui.FlatDropShadowBorder;
|
||||||
import com.formdev.flatlaf.ui.FlatPopupMenuBorder;
|
import com.formdev.flatlaf.ui.FlatPopupMenuBorder;
|
||||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
@@ -98,8 +100,14 @@ class HintManager
|
|||||||
public void updateUI() {
|
public void updateUI() {
|
||||||
super.updateUI();
|
super.updateUI();
|
||||||
|
|
||||||
|
if( UIManager.getLookAndFeel() instanceof FlatLaf ) {
|
||||||
setBackground( UIManager.getColor( "HintPanel.backgroundColor" ) );
|
setBackground( UIManager.getColor( "HintPanel.backgroundColor" ) );
|
||||||
setBorder( new FlatPopupMenuBorder() );
|
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() {
|
void showHint() {
|
||||||
@@ -115,10 +123,12 @@ class HintManager
|
|||||||
public void updateUI() {
|
public void updateUI() {
|
||||||
super.updateUI();
|
super.updateUI();
|
||||||
|
|
||||||
|
if( UIManager.getLookAndFeel() instanceof FlatLaf ) {
|
||||||
setBorder( new FlatDropShadowBorder(
|
setBorder( new FlatDropShadowBorder(
|
||||||
UIManager.getColor( "Popup.dropShadowColor" ),
|
UIManager.getColor( "Popup.dropShadowColor" ),
|
||||||
UIManager.getInsets( "Popup.dropShadowInsets" ),
|
UIManager.getInsets( "Popup.dropShadowInsets" ),
|
||||||
FlatUIUtils.getUIFloat( "Popup.dropShadowOpacity", 0.5f ) ) );
|
FlatUIUtils.getUIFloat( "Popup.dropShadowOpacity", 0.5f ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
// use invokeLater because at this time the UI delegates
|
// use invokeLater because at this time the UI delegates
|
||||||
// of child components are not yet updated
|
// of child components are not yet updated
|
||||||
|
|||||||
Reference in New Issue
Block a user