01: /*
02: * This program is free software; you can redistribute it and/or
03: * modify it under the terms of the GNU General Public License
04: * as published by the Free Software Foundation; either version 2
05: * of the License, or (at your option) any later version.
06: *
07: * This program is distributed in the hope that it will be useful,
08: * but WITHOUT ANY WARRANTY; without even the implied warranty of
09: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10: * GNU General Public License for more details.
11:
12: * You should have received a copy of the GNU General Public License
13: * along with this program; if not, write to the Free Software
14: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15: */
16: package net.sf.jftp.gui.tasks;
17:
18: import net.sf.jftp.config.Settings;
19: import net.sf.jftp.gui.*;
20: import net.sf.jftp.gui.framework.*;
21: import net.sf.jftp.util.*;
22:
23: import java.awt.*;
24:
25: import java.io.*;
26:
27: import java.net.*;
28:
29: import java.util.*;
30:
31: import javax.swing.*;
32:
33: public class ImageViewer extends JInternalFrame {
34: public ImageViewer(String img) {
35: super (img, true, true, true, true);
36: setLocation(150, 50);
37: setSize(400, 300);
38:
39: setLayout(new BorderLayout(2, 2));
40:
41: ImagePanel p = new ImagePanel(img);
42: JScrollPane scroll = new JScrollPane(p);
43:
44: getContentPane().add("Center", scroll);
45:
46: p.setMinimumSize(new Dimension(1500, 1500));
47: p.setPreferredSize(new Dimension(1500, 1500));
48: p.setMaximumSize(new Dimension(1500, 1500));
49:
50: setVisible(true);
51:
52: //doLayout();
53: //validate();
54: //p.repaint();
55: //Log.out(""+p.getSize().width);
56: }
57: }
58:
59: class ImagePanel extends JPanel {
60: private Image img;
61:
62: public ImagePanel(String url) {
63: try {
64: setBackground(Color.white);
65:
66: img = Toolkit.getDefaultToolkit().getImage(new URL(url));
67:
68: MediaTracker mt = new MediaTracker(this );
69: mt.addImage(img, 1);
70: mt.waitForAll();
71:
72: //System.out.println(img);
73: //setVisible(true);
74: repaint();
75:
76: //validate();
77: } catch (Exception ex) {
78: ex.printStackTrace();
79: }
80: }
81:
82: public void paintComponent(Graphics g) {
83: g.setColor(Color.white);
84: g.fillRect(0, 0, 1500, 1500);
85: g.drawImage(img, 0, 0, null);
86: }
87:
88: public void update(Graphics g) {
89: paintComponent(g);
90: }
91: }
|