Here such an error occurs, how to fix it please help:
Exception in thread "AWT-EventQueue-0" java.lang. IllegalArgumentException: Width (0) and height (0) must be non-zero

ResultSet resultSet = connection.query("select url_image from "+name+" where id = "+List.get(i)); java.sql.Blob blob = null; try { while (resultSet.next()) { blob = resultSet.getBlob("url_image"); } } catch (SQLException e4) { e4.printStackTrace(); } BufferedImage destImage = null; try { destImage = ImageIO.read(blob.getBinaryStream()); } catch (IOException e1) { e1.printStackTrace(); } catch (SQLException e1) { e1.printStackTrace(); } Image scaledImage = destImage.getScaledInstance(photoLabel.getWidth(),photoLabel.getHeight(), Image.SCALE_DEFAULT); // вот здесь возникает ошибка ImageIcon imgIc = new ImageIcon(scaledImage); photoLabel.setIcon(imgIc); 

Here is the code from the Jlabel element

  photoLabel = new javax.swing.JLabel(); .addComponent(photoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 367, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(photoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) private javax.swing.JLabel photoLabel; 
  • one
    for this fragment you cannot say for sure - the error itself is not there, but with photoLabel - for some reason it has zero dimensions (ps launching the fragment will give more chances to help you, just by the way) - OldTeaOwl
  • give more code - michael_best
  • So what's wrong here? - user275180

1 answer 1

try setting photoLabel dimensions

 JLabel photoLabel = new JLabel(); Dimension dim = new Dimension(367,367); photoLabel.setMinimumSize(dim); photoLabel.setMaximumSize(dim);