java applet GUI question

C

Claus K.

Hello everyone,

I have written this small applet GUI some time ago (more as proof of
concept than anything else); now there actually is a new requirement
for it.

The applet GUI is basically a telnet client, with some custom
functionality built in, which is all working fine.
However, now the stream output arriving should be coloured when there
is colour specified.

The first version was just written in plain AWT, with all the telnet
color code removed via regex.
Now, I am looking for what to do.

I have found the swing Components, of course, and it appears as if I
could do exactly what I want with a JTextPane, but the Document
instance as model behind is confusing me a bit.
Can I just add the stream output to the document with color
information when specified and update the JTextPane to show the
document again? How does that work with limiting scrollback and fast
arriving data over the stream?
 
K

Knute Johnson

Claus said:
Hello everyone,

I have written this small applet GUI some time ago (more as proof of
concept than anything else); now there actually is a new requirement
for it.

The applet GUI is basically a telnet client, with some custom
functionality built in, which is all working fine.
However, now the stream output arriving should be coloured when there
is colour specified.

The first version was just written in plain AWT, with all the telnet
color code removed via regex.
Now, I am looking for what to do.

I have found the swing Components, of course, and it appears as if I
could do exactly what I want with a JTextPane, but the Document
instance as model behind is confusing me a bit.
Can I just add the stream output to the document with color
information when specified and update the JTextPane to show the
document again? How does that work with limiting scrollback and fast
arriving data over the stream?

JTextPane has limited capabilities to display a couple of different
markup types (HTML and RTF). I think it would work just fine for what
you want to do. You should be able to just append text to the document.
 
D

Daniel Pitts

Claus said:
Hello everyone,

I have written this small applet GUI some time ago (more as proof of
concept than anything else); now there actually is a new requirement
for it.

The applet GUI is basically a telnet client, with some custom
functionality built in, which is all working fine.
However, now the stream output arriving should be coloured when there
is colour specified.

The first version was just written in plain AWT, with all the telnet
color code removed via regex.
Now, I am looking for what to do.

First, Color is not usually "telnet" code, it is terminal code. Look up
VT220 emulation for a start.
I have found the swing Components, of course, and it appears as if I
could do exactly what I want with a JTextPane, but the Document
instance as model behind is confusing me a bit.
Can I just add the stream output to the document with color
information when specified and update the JTextPane to show the
document again? How does that work with limiting scrollback and fast
arriving data over the stream?

That I can't help you with. What have you tried? What happened?
 
R

Roedy Green

The first version was just written in plain AWT, with all the telnet
color code removed via regex.
Now, I am looking for what to do.

Probably the easiest way to do it is to mark up your stream with some
simple HTML markup and feed it to a JEditorPane.
see http://mindprod.com/jgloss/jeditorpane.html

You can do it in AWT by using drawString on a Canvas, very low level.

--
Roedy Green Canadian Mind Products
http://mindprod.com

"Climate change is no longer a doomsday prophecy, it’s a reality."
~ Astrid Heiberg president of the International Federation of Red Cross and Red Crescent Societies
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top