[JAVA] Desktop: Gui show image

Goal
Load a image with OpenCV.

Gui_Show_Image.java


mport javax.swing.*;
import java.awt.*;

public class Gui_Show_Image {

    private JFrame frame;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    Gui_Show_Image window = new Gui_Show_Image();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    public Gui_Show_Image() {
        initialize();
    }
    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 450, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);

        JLabel lblNewLabel = new JLabel("");
        lblNewLabel.setIcon(new ImageIcon("C:\\Users\\koinPC\\Pictures\\dance2.png "));
        lblNewLabel.setBounds(14, 0, 159, 240);
        frame.getContentPane().add(lblNewLabel);
    }
}
Result
![ShowImage.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/276243/99b9dd04-9144-e5be-02fc-4b3ececb70fb.jpeg)

Recommended Posts

Desktop: Gui show image
Desktop: Gui slider
Desktop: Gui Button
Desktop: OpenCV Sharpness Gui
Desktop: OpenCV resize image
Desktop: OpenCV Flip image
Desktop: OpenCV Rotate image
Desktop: OpenCV Gui modify Brightness
Desktop: OpenCV Merge Two Image
Desktop: OpenCV Show Stylization By WebCam
Desktop: OpenCV Gui change every pixel
Show preview when editing user image