TextViewerpublic class TextViewer extends Panel implements CommandObject
Fields Summary |
---|
private TextArea | text_area | private File | text_file | private String | text_buffer | private DataHandler | _dh | private boolean | DEBUG |
Constructors Summary |
---|
public TextViewer()Constructor
setLayout( new GridLayout(1,1));
// create the text area
text_area = new TextArea("", 24, 80,
TextArea.SCROLLBARS_VERTICAL_ONLY );
text_area.setEditable( false );
add(text_area);
|
Methods Summary |
---|
public void | addNotify()
super.addNotify();
invalidate();
| public java.awt.Dimension | getPreferredSize()
return text_area.getMinimumSize(24, 80);
| public void | setCommandContext(java.lang.String verb, javax.activation.DataHandler dh)
_dh = dh;
this.setInputStream( _dh.getInputStream() );
| public void | setInputStream(java.io.InputStream ins)set the data stream, component to assume it is ready to
be read.
int bytes_read = 0;
// check that we can actually read
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte data[] = new byte[1024];
while((bytes_read = ins.read(data)) >0)
baos.write(data, 0, bytes_read);
ins.close();
// convert the buffer into a string
// popuplate the buffer
text_buffer = baos.toString();
// place in the text area
text_area.setText(text_buffer);
|
|