close

I used to beaten by the complex code when I want to show a picture using  Java GUI

However, I sucess today ....

Below is what I've implemented:

1. convert BufferedImage type to ImageIcon ex:  ImageIcon icon=new ImageIcon(bufferedImage);

2. creat object JLabel ex:  JLabel label=new JLabel(icon);

3. creat object JFrame :

         JFrame frame=new JFrame("Result");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.add(label);
         frame.setSize(200,200);
         frame.setVisible(true);

4. Now you can display the result image. 

arrow
arrow
    全站熱搜

    davidctwood 發表在 痞客邦 留言(0) 人氣()