Hi. I'm really new in programming java and do need some help now. How do I add some images (jpg-files, path out of a database) to a JPanel which extends a JScrollPane. The images should be resized to a thumbnail-size.
Your best bet is to create JLabels inside your panel to apply the images to. So you code for that would be something like [CODE] ImageIcon myIcon = new ImageIcon("path\\to\\file.jpg"); JLabel myLabel = new JLabel(myIcon2); [\CODE] Now, where does myIcon2 come from?? Well, to resize the image to a thumbnail size you do something like this: [CODE] Image img = myIcon.getImage(); Image newimg = img.getScaledInstance(230, 310, Image.SCALE_SMOOTH); myIcon2 = new ImageIcon(newimg); [\CODE] Your labels should be set to a size the same as what size your Images will be scaled to. Hope that helps Gregg
It runs on an internal combustion engine. This ad does not: