1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| try {
File[] images = selectedFile.listFiles(imageIOFilter);
int imagesCount = 0;
for (File file : images) {
imagesCount += addImage(file);
.......
public int addImage(File file) {
int printed = 0;
try {
if (this.getJPanel().add(new ThumbnailPanel(file, 0, 0, true, true, this.imageIcon, this.imageIcon2)) != null) {
if (showImagesLoadingProgress)
this.getJPanel().paintAll(this.getJPanel().getGraphics());
printed = 1;
}
} catch (IOException e) {
e.printStackTrace();
}
return printed;
}
// ********ensuite les JPanels ThumbnailPanel
private JImagePanel createJImagePanel(File file, int x, int y, boolean autoSize, boolean keepAspect) throws IOException {
if (jImagePanel == null) {
jImagePanel = new JImagePanel(file, x, y, autoSize, keepAspect, DEFAULT_ALIGNEMENT);
}
return jImagePanel;
}
//********* autre JPanel JImagePanel
setImage(ImageIO.read(file));
public void setImage(Image image) {
this.image = image;
}
public Image getImage() {
return this.image;
}
public void setImage(File file) {
try {
setImage(ImageIO.read(file));
} catch (IOException e) {
e.printStackTrace();
}
} |
Partager