I write java desktop (netbeans). But unfortunately I can not find the option of downloading photos with the preservation of proportions (the size of the photo is different). And how to load a photo in full size (place it on the form) with scroll bars? I would appreciate if someone responds. Time is running out, but I have not found the option for a week. You need something like this: enter image description here

Here is one of the options (:

jFileChooser1.showOpenDialog(this); File file2 = jFileChooser1.getSelectedFile(); BufferedImage image=null; try { image=ImageIO.read(file2); } catch (IOException ex) { Logger.getLogger(NewApplication.class.getName()).log(Level.SEVERE, null, ex); } int hl= image.getHeight(); int wl= image.getWidth(); int hi ; int wi; hi=hl; wi=wl; Icon icon; icon = new ImageIcon(image.getScaledInstance(wi, hi, BufferedImage.SCALE_DEFAULT)); jLabel6.prepareImage(image, this); jLabel6.setIcon((icon)); 
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

Briefly: instead of .add(myJPanel); - .add(new JScrollPane(myJPanel)); . Here is more: https://javaswing.wordpress.com/2009/08/04/jscrollpane_using/ . And what is meant by loading with the preservation of proportions? The file is loaded as is. If processing is needed, it must be done after receiving the contents of the file.

  • Thanks for the hint. ) It is necessary jLabel to assign the size of the picture, jLabel should be on the JPanel on which should be JScrollPane? I understand correctly? Tell me plz ... - Vitali
  • Understood thank you very much))))))) Can someone tell me how to scale a mouse scroll ????? - Vitali