FlickrPhoto photo=new FlickrPhoto();
public PhotoApp() throws Exception {
super("Aggregierte Fotos aus Flickr");
final Container cont=getContentPane();
final JPanel panel1=new JPanel();
final JPanel panel2=new JPanel();
//panel1.setLayout(new BorderLayout());
// Scrollbar
JScrollPane jscroll = new JScrollPane(panel1);
jscroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
List<URL> imgList = photo.fetchImage();
// Flickr Bild 1
ImageIcon icon=new ImageIcon(imgList.get(0));
final ImageIcon icon_original=new ImageIcon(imgList.get(0));
icon.setImage(icon.getImage().getScaledInstance(70, 70, Image.SCALE_DEFAULT));
final JLabel label1=new JLabel(icon);
// MouseListener für label1 und dem Icon
label1.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent e) {
JLabel label_original=new JLabel(icon_original);
panel2.add(label_original);
cont.add(panel2,BorderLayout.CENTER);
cont.validate();
cont.update(cont.getGraphics());
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
}
);
//Flickr Bild 2
ImageIcon icon1=new ImageIcon(imgList.get(1));
final ImageIcon icon_original1=new ImageIcon(imgList.get(1));
icon1.setImage(icon1.getImage().getScaledInstance(70, 70, Image.SCALE_DEFAULT));
JLabel label2=new JLabel(icon1);
label2.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent e) {
JLabel label_original1=new JLabel(icon_original1);
panel2.add(label_original1);
cont.add(panel2,BorderLayout.CENTER);
cont.validate();
cont.update(cont.getGraphics());
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
}
);
//Flickr Bild 3
ImageIcon icon2=new ImageIcon(imgList.get(2));
final ImageIcon icon_original2=new ImageIcon(imgList.get(2));
icon2.setImage(icon2.getImage().getScaledInstance(70, 70, Image.SCALE_DEFAULT));
JLabel label3=new JLabel(icon2);
label3.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent e) {
JLabel label_original2=new JLabel(icon_original2);
panel2.add(label_original2);
cont.add(panel2,BorderLayout.CENTER);
cont.validate();
cont.update(cont.getGraphics());
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
});
// Flickr Bild 4
ImageIcon icon3=new ImageIcon(imgList.get(3));
final ImageIcon icon_original3=new ImageIcon(imgList.get(3));
icon3.setImage(icon3.getImage().getScaledInstance(70, 70, Image.SCALE_DEFAULT));
JLabel label4=new JLabel(icon3);
label4.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent e) {
JLabel label_original3=new JLabel(icon_original3);
panel2.add(label_original3);
cont.add(panel2,BorderLayout.CENTER);
cont.validate();
cont.update(cont.getGraphics());
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
}
);
// Flickr Bild 5
ImageIcon icon4=new ImageIcon(imgList.get(4));
final ImageIcon icon_original4=new ImageIcon(imgList.get(4));
icon4.setImage(icon4.getImage().getScaledInstance(70, 70, Image.SCALE_DEFAULT));
JLabel label5=new JLabel(icon4);
label5.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent e) {
JLabel label_original4=new JLabel(icon_original4);
panel2.add(label_original4);
cont.add(panel2,BorderLayout.CENTER);
cont.validate();
cont.update(cont.getGraphics());
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
});
ImageIcon icon5=new ImageIcon(imgList.get(5));
icon5.setImage(icon5.getImage().getScaledInstance(70, 70, Image.SCALE_DEFAULT));
JLabel label6=new JLabel(icon5);
ImageIcon icon6=new ImageIcon(imgList.get(6));
icon6.setImage(icon6.getImage().getScaledInstance(70, 70, Image.SCALE_DEFAULT));
JLabel label7=new JLabel(icon6);
ImageIcon icon7=new ImageIcon(imgList.get(7));
icon7.setImage(icon7.getImage().getScaledInstance(70, 70, Image.SCALE_DEFAULT));
JLabel label8=new JLabel(icon7);
ImageIcon icon8=new ImageIcon(imgList.get(8));
icon8.setImage(icon8.getImage().getScaledInstance(70, 70, Image.SCALE_DEFAULT));
JLabel label9=new JLabel(icon8);
ImageIcon icon9=new ImageIcon(imgList.get(9));
icon9.setImage(icon9.getImage().getScaledInstance(70, 70, Image.SCALE_DEFAULT));
JLabel label10=new JLabel(icon9);
// Labels mit Fotos auf Panel setzen
panel1.add(label1);
panel1.add(label2);
panel1.add(label3);
panel1.add(label4);
panel1.add(label5);
panel1.add(label6);
panel1.add(label7);
panel1.add(label8);
panel1.add(label9);
panel1.add(label10);
cont.add(panel1,BorderLayout.SOUTH);
}
// }
public static void main(String args[]) {
PhotoApp app = null;
try {
app = new PhotoApp();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
app.setSize(600, 600);
app.setVisible(true);
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}