Debian Codegraph @

demo/src/main/java/TextInternalizer.java

raw
1 /*
2 * Copyright (c) 1997, 2019 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Distribution License v. 1.0, which is available at
6 * http://www.eclipse.org/org/documents/edl-v10.php.
7 *
8 * SPDX-License-Identifier: BSD-3-Clause
9 */
10
11 import java.awt.*;
12 import java.io.*;
13 import java.beans.*;
14 import jakarta.activation.*;
15
16 public class TextInternalizer extends Panel implements Externalizable {
17 // UI Vars...
18 private TextArea text_area = null;
19
20 // File Vars
21 private File text_file = null;
22 private String text_buffer = null;
23
24 private DataHandler _dh = null;
25 private boolean DEBUG = false;
26 /**
27 * Constructor
28 */
29 public TextInternalizer() {
30 System.out.println("TextInternalizer!!!!!");
31
32 setLayout( new GridLayout(1,1));
33 // create the text area
34 text_area = new TextArea("", 24, 80,
35 TextArea.SCROLLBARS_VERTICAL_ONLY );
36 text_area.setEditable( false );
37
38 add(text_area);
39 }
40
41 public void writeExternal(ObjectOutput out) throws IOException{
42
43 }
44
45 public void readExternal(ObjectInput in) throws IOException,
46 ClassNotFoundException {
47
48
49 this.setObjectInput(in);
50 }
51
52
53
54 //--------------------------------------------------------------------
55 // public void setCommandContext(String verb, DataHandler dh) throws IOException {
56 // _dh = dh;
57 // this.setInputStream( _dh.getInputStream() );
58 // }
59 //--------------------------------------------------------------------
60
61 /**
62 * set the data stream, component to assume it is ready to
63 * be read.
64 */
65 public void setObjectInput(ObjectInput ins) throws IOException {
66 try {
67
68 text_buffer = (String)ins.readObject();
69 } catch(Exception e){ e.printStackTrace(); }
70 // place in the text area
71 text_area.setText(text_buffer);
72
73 }
74 //--------------------------------------------------------------------
75 public void addNotify() {
76 super.addNotify();
77 invalidate();
78 }
79 //--------------------------------------------------------------------
80 public Dimension getPreferredSize() {
81 return text_area.getMinimumSize(24, 80);
82 }
83
84 }
85
86
87
88
89
90