KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > filetransfer > cif > FileTransfertPDA_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 java.lang.*;
36
37 public class FileTransfertPDA_impl {
38
39     //private TextArea textAr_ = null;
40
private Canvas screen_ = null;
41     private Button channel_ = null;
42     private Button welcome_ = null;
43     
44     private Image img = null;
45
46     //
47
// The FileTransfert_impl object constructor to initialize the Receiver's GUI
48
//
49

50     FileTransfertPDA_impl(Canvas screen, Button channel, Button welcome) {
51
52         //textAr_ = textarea;
53
screen_ = screen;
54         channel_ = channel;
55         welcome_ = welcome;
56         
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
69         java.io.File JavaDoc currentdir = new java.io.File JavaDoc(System.getProperty("user.dir"));
70         
71         
72         currentdir = new java.io.File JavaDoc(currentdir.getParent());
73
74         try {
75             file =
76                 new FileOutputStream(currentdir.getParent() + "/IMAGE/Receive/" + filename);
77             file.write(last_send);
78             file.close();
79
80         } catch (java.io.IOException JavaDoc ex) {
81             System.err.println("Can't write to " + ": " + ex.getMessage());
82             System.exit(1);
83         }
84
85         
86     }
87     
88     public void display_image(byte[] last_send, String JavaDoc filename) {
89         
90         
91         channel_.setLabel("<" + filename + ">");
92
93         // Display the received image
94

95         
96         // Load lastImage[]
97
img = Toolkit.getDefaultToolkit().createImage(last_send);
98         
99         // delete previous image
100
screen_.getGraphics().dispose();
101         screen_.update(screen_.getGraphics());
102         // get Graphics and draw image
103
screen_.getGraphics().drawImage(img,0,0,welcome_);
104         
105         // Store the received file
106
//this.storeLastSend(last_send, filename);
107

108         
109     }
110
111 }
112
Popular Tags