public final class ImageIcon extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ImageIcon.Builder
|
Modifier and Type | Method and Description |
---|---|
static IIcon |
create(String filePath)
Create an
IIcon from a PNG or JPEG file. |
static ImageIcon.Builder |
newBuilder()
Creates a Builder which allows to construct an
IIcon based on 1 or more images. |
static IIcon |
toIcon(Image image)
Converts an
Image to an Icon. |
@NotNull public static IIcon create(@NotNull String filePath) throws RuntimeException
IIcon
from a PNG or JPEG file.
Will throw a RuntimeError if the file does not contain any valid data or if the file format could not be recognized.
It accepts icon files with following naming convention.
<name>.<ext>
where <ext>
is PNG or JPEG.
f
is named <name>@<f>x.<ext>
. f
is typically a value like 2 or 4. See the article on high DPI for additional information.
filePath
- a file pathIIcon
from a PNG or JPEG fileRuntimeException
- if the file does not contain any valid data or if the file format could not be recognized.@NotNull public static IIcon toIcon(@NotNull Image image) throws NullPointerException
Image
to an Icon.
The used display scale is 1. The anchor point of the icon is at the center of the image.
IIcon
.NullPointerException
- when passing a null
value.@NotNull public static ImageIcon.Builder newBuilder()
IIcon
based on 1 or more images.