Java JTextField readBufferedImage(JTextField out)

Here you can find the source of readBufferedImage(JTextField out)

Description

Reads an image file from disk and returns and BufferedImage.

License

Open Source License

Parameter

Parameter Description
out The output stream to write error messages to.

Return

A BufferedImage object of the image file.

Declaration

public static BufferedImage readBufferedImage(JTextField out) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import javax.imageio.ImageIO;
import javax.swing.JTextField;
import java.awt.image.BufferedImage;

import java.io.File;
import java.io.IOException;

public class Main {
    /**/*ww  w  .j a  v a2 s . c  om*/
     * Reads an image file from disk and returns and BufferedImage.
     *
     * @param out The output stream to write error messages to.
     * @return A BufferedImage object of the image file.
     */
    public static BufferedImage readBufferedImage(JTextField out) {
        BufferedImage image = null;
        File fileLocation = new File("img/balls.gif");
        try {
            image = ImageIO.read(fileLocation);
        } catch (IOException e) {
            out.setText(String.format("Could not open image: %s", "img/balls.gif"));
        }
        return image;
    }
}

Related

  1. newIntegerValue(JTextField text, int oldValue)
  2. onTextFieldChange(JTextField field, final Runnable task)
  3. parseTextFieldInteger(JTextField field)
  4. ponerMayuscula(KeyEvent e, JTextField textField)
  5. quickButtonFlip(JTextField t, JTextField a, JTextField b)
  6. secureTextDeletionFromTextField(JTextField textField, int length)
  7. setEnabled(JTextField textField, boolean b)
  8. setEnabled(JTextField textField, boolean enabled)
  9. setModelValue(JTextField tf, String value)