Class SwingFXUtils
- javafx.embed.swing.SwingFXUtils
public class SwingFXUtils extends Object
Since:
JavaFX 2.2
-
Method Summary
All MethodsStatic MethodsConcrete Methods Modifier and Type Method and Description static BufferedImagefromFXImage(Image img, BufferedImage bimg)Snapshots the specified JavaFXImageobject and stores a copy of its pixels into aBufferedImageobject, creating a new object if needed.static WritableImagetoFXImage(BufferedImage bimg, WritableImage wimg)Snapshots the specifiedBufferedImageand stores a copy of its pixels into a JavaFXImageobject, creating a new object if needed.
-
Method Detail
-
toFXImage
public static WritableImage toFXImage(BufferedImage bimg, WritableImage wimg)Snapshots the specifiedBufferedImageand stores a copy of its pixels into a JavaFXImageobject, creating a new object if needed. The returnedImagewill be a static snapshot of the state of the pixels in theBufferedImageat the time the method completes. Further changes to theBufferedImagewill not be reflected in theImage.The optional JavaFX
WritableImageparameter may be reused to store the copy of the pixels. A newImagewill be created if the supplied object is null, is too small or of a type which the image pixels cannot be easily converted into.Parameters:
bimg- theBufferedImageobject to be convertedReturns:
an
Imageobject representing a snapshot of the current pixels in theBufferedImage.Since:
JavaFX 2.2
-
fromFXImage
public static BufferedImage fromFXImage(Image img, BufferedImage bimg)Snapshots the specified JavaFXImageobject and stores a copy of its pixels into aBufferedImageobject, creating a new object if needed. The method will only convert a JavaFXImagethat is readable as per the conditions on theImage.getPixelReader()method. If theImageis not readable, as determined by itsgetPixelReader()method, then this method will return null. If theImageis a writable, or other dynamic image, then theBufferedImagewill only be set to the current state of the pixels in the image as determined by itsPixelReader. Further changes to the pixels of theImagewill not be reflected in the returnedBufferedImage.The optional
BufferedImageparameter may be reused to store the copy of the pixels. A newBufferedImagewill be created if the supplied object is null, is too small or of a type which the image pixels cannot be easily converted into.Parameters:
img- the JavaFXImageto be convertedReturns:
a
BufferedImagecontaining a snapshot of the JavaFXImage, or null if theImageis not readable.Since:
JavaFX 2.2
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.