KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > filetransfer > cif > FileTransfert_impl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Areski Flissi.
23 Contributor(s):
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.filetransfer.cif;
28
29 /**
30  * @author <a HREF="mailto:Areski.Flissi@lifl.fr">Areski Flissi</A>
31  */

32
33 import java.io.*;
34 import java.awt.*;
35 import javax.swing.*;
36 import java.lang.*;
37
38 public class FileTransfert_impl {
39
40     
41     
42     private JButton label_ = null;
43     private Image img = null;
44     private JButton screen_ = null;
45     private javax.swing.ImageIcon JavaDoc imgicon = null;
46     
47
48     //
49
// The FileTransfert_impl object constructor to initialize the Receiver's GUI
50
//
51

52     FileTransfert_impl(JButton screen, JButton label) {
53
54         
55         screen_ = screen;
56         label_ = label;
57         screen_.setBackground(Color.white);
58
59     }
60
61     //
62
// A method to store received files for each channel
63
//
64

65     public void storeLastSend(byte[] last_send, String JavaDoc filename) {
66
67         FileOutputStream file = null;
68         java.io.File JavaDoc currentdir = new java.io.File JavaDoc(System.getProperty("user.dir"));
69         currentdir = new java.io.File JavaDoc(currentdir.getParent());
70
71         System.out.println("=== " + currentdir.getParent() + "/IMAGE/Receive/" + filename);
72
73         try {
74             file =
75                 new FileOutputStream(currentdir.getParent() + "/IMAGE/Receive/" + filename);
76             file.write(last_send);
77             file.close();
78
79         } catch (java.io.IOException JavaDoc ex) {
80             System.err.println("Can't write to " + ": " + ex.getMessage());
81             System.exit(1);
82         }
83     }
84     
85     public synchronized void display_image(byte[] last_send, String JavaDoc filename) {
86         
87         // Display the received image
88
label_.setLabel("<<" + filename + ">>");
89         imgicon = new javax.swing.ImageIcon JavaDoc(last_send);
90         screen_.setIcon(imgicon);
91     }
92
93 }
94
Popular Tags