+ 1

Please Help me Guys. I don't know why this code is not showing any image nor any error message. Below are my codes.

ImageIcon img = new ImageIcon(""); JLabel pixLabel = new JLabel(); int chk = 1; try { PreparedStatement prdst = con.prepareStatement("SELECT image FROM fuoye_medical.patient_image WHERE patient_id="+chk); ResultSet rs = prdst.executeQuery(); rs.next(); Blob b = rs.getBlob("image"); byte[] buf = null; buf = b.getBytes(1, (int)b.length()); Image i = Toolkit.getDefaultToolkit().createImage(buf); ImageIcon ii = new ImageIcon(i); Image iii = ii.getImage().getScaledInstance(pixLabel.getWidth(), pixLabel.getHeight(), Image.SCALE_SMOOTH); img = new ImageIcon(iii); pixLabel.setIcon(img); } catch(Exception ex){ ex.printStackTrace(); }

6th Jun 2021, 6:01 AM
BAYODE BLESSING AKINBOLA
2 Respostas
+ 2
And did you add the pixelLabel to your JFrame? Here is a small example how to show images: http://www.java2s.com/Tutorials/Java/Graphics_How_to/Image/Display_Image_with_Swing_GUI.htm
6th Jun 2021, 8:11 AM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Yes, the JLabel had been added to JFrame
6th Jun 2021, 12:56 PM
BAYODE BLESSING AKINBOLA