You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After the addition of FlatHTML (261d2b1), setting an HTML text on a component with a null font will throw a NullPointerException.
While this is probably a very unlikely scenario, since the vanilla java theme support components with null fonts and HTML text, it may be best for FlatLaf to also support it.
If not, this restriction should probably be explicit.
Sample code to reproduce:
importcom.formdev.flatlaf.FlatLightLaf;
importjavax.swing.*;
importjava.awt.*;
classScratch {
publicstaticvoidmain(String[] args) {
FlatLightLaf.setup(); // commenting this line, no NPE is thrown with the label font being nullSwingUtilities.invokeLater(() -> {
JFrameframe = newJFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(newBorderLayout(10, 10));
JLabellabel = newJLabel();
label.setFont(null); // commenting this line, no NPE is thrown with FlatLaf theme being activelabel.setText("<html><h1>foo</h1><h2>bar</h2></html>");
frame.getContentPane().add(label, BorderLayout.CENTER);
frame.setSize(newDimension(100, 100));
frame.setLocationRelativeTo(null);
frame.setVisible(true);
});
}
}
Stack trace:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "java.awt.Font.getSize()" because "font" is null
at com.formdev.flatlaf.ui.FlatHTML.updateRendererCSSFontBaseSize(FlatHTML.java:75)
at com.formdev.flatlaf.ui.FlatHTML.propertyChange(FlatHTML.java:243)
at com.formdev.flatlaf.ui.FlatLabelUI.propertyChange(FlatLabelUI.java:131)
at java.desktop/java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:343)
at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:335)
at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:268)
at java.desktop/java.awt.Component.firePropertyChange(Component.java:8717)
at java.desktop/javax.swing.JComponent.putClientProperty(JComponent.java:4180)
at java.desktop/javax.swing.plaf.basic.BasicHTML.updateRenderer(BasicHTML.java:232)
at java.desktop/javax.swing.plaf.basic.BasicLabelUI.propertyChange(BasicLabelUI.java:493)
at com.formdev.flatlaf.ui.FlatLabelUI.propertyChange(FlatLabelUI.java:130)
at java.desktop/java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:343)
at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:335)
at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:268)
at java.desktop/java.awt.Component.firePropertyChange(Component.java:8717)
at java.desktop/javax.swing.JLabel.setText(JLabel.java:341)
at Scratch.lambda$main$0(scratch_12.java:17)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
The text was updated successfully, but these errors were encountered:
After the addition of
FlatHTML
(261d2b1), setting an HTML text on a component with anull
font will throw aNullPointerException
.While this is probably a very unlikely scenario, since the vanilla java theme support components with null fonts and HTML text, it may be best for FlatLaf to also support it.
If not, this restriction should probably be explicit.
Sample code to reproduce:
Stack trace:
The text was updated successfully, but these errors were encountered: