• Post Reply Bookmark Topic Watch Topic
  • New Topic

Two quick questions  RSS feed

 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi people.

I wonder if someone could help me. I have made a simple chat program with a JTextArea to show the incoming text (each machine has its own Swing interface). When one types in a message (in a different JTextArea), the JScrollPane works fine and auto scrolls each time the message is sent. But the problem is that when an incoming message comes in and prints out in JTextArea, it doesn't do any type of auto scrolling, i mean, the scroll bar moves up as if there is the new text, but one has to manually scroll down to see this new text.

Any ideas?

Also how can i make the windows blink or something to let one know that they have received a message?

Thanks in advance and best regards,
Marzo.
 
Stephen Boston
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if this helps you.
JScrollPane and JTextArea

hth
Steve
 
Stephen Boston
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The window blink is a bit tougher. My research shows for windows you need a Jini app and some C code.
(Beyond my skill level at present )

If you are using a MAC it is much easier according to the linked article.

But - see if this helps.

Blink/Flash JFrame
[ September 01, 2005: Message edited by: Stephen Boston ]
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stephen
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using JDK 1.5 you could use the TrayIcon from the JDIC project instead of blinking the frame. Also, if you are writing a chat application, unless you are just trying to learn, there are hundreds of them already written in java with source available. Just google for them.
 
Stephen Boston
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the forums I had come across on the blink/flash jFrame suggested to just change the jFrame icon to a negative image and then back.

Perhaps a timer to do the flipping for you? I'm not sure what it would do on the windows task bar though (and I sure don't know what it will do on a MAC. )

BTW; when I say something like that, please bear in mind that I'm not putting down the MAC, I just have ZERO experience with one.
[ September 01, 2005: Message edited by: Stephen Boston ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could use a DocumentListener

in this example, I just get it to 'beep' - change this to a blinking label, or whatever

this example doesn't display the autoscroll problem you have, but all you'd
have to do is add this line (in the documentListener)
taBottom.setCaretPostion(taBottom.getDocument().getLength());

to run the program, enter something in the top textarea, then click send,
and it will appear appended to the bottom textArea

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!