mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
ScaledImageIcon: do not throw exceptions if image has invalid size (e.g. not found); instead paint a red rectangle (similar to FlatSVGIcon)
This commit is contained in:
@@ -13,6 +13,8 @@ FlatLaf Change Log
|
||||
button.
|
||||
- Arrow buttons in ComboBox, Spinner, ScrollBar and TabbedPane: Show "pressed"
|
||||
feedback only for left mouse button.
|
||||
- ScaledImageIcon: Do not throw exceptions if image was has invalid size (e.g.
|
||||
not found). Instead, paint a red rectangle (similar to `FlatSVGIcon`).
|
||||
|
||||
|
||||
## 2.5
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.formdev.flatlaf.util;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
@@ -102,6 +103,13 @@ debug*/
|
||||
int imageWidth = image.getWidth( null );
|
||||
int imageHeight = image.getHeight( null );
|
||||
|
||||
// paint red rectangle if image has invalid size (e.g. not found)
|
||||
if( imageWidth < 0 || imageHeight < 0 ) {
|
||||
g.setColor( Color.red );
|
||||
g.fillRect( x, y, getIconWidth(), getIconHeight() );
|
||||
return;
|
||||
}
|
||||
|
||||
// scale image if necessary to destination size
|
||||
if( imageWidth != destImageWidth || imageHeight != destImageHeight ) {
|
||||
// determine scaling method; default is "quality"
|
||||
|
||||
Reference in New Issue
Block a user