Hi! I am just wondering how can I make the title bar of a JFrame to be Marquee . Is it possible to do that? Thanks a lot!
+2
A:
Please don't.
If you do decide to, then the obvious technique is to setTitle with a subsequence of the required text. I guess various partial sized spaces in Unicode may allow you to make the slightly smoother (or they might appear as squares).
Alternatively, you could make the window PL&F decorated (wont work with the native PL&F in the Sun/Oracle implementation) and draw the text yourself. To look good, you'd need to tune it to the particular PL&F and configuration.
Tom Hawtin - tackline
2010-03-22 06:25:42
hi Tom your first suggestion is interesting but how can I do that?
twintwins
2010-03-22 07:58:29
I think Tom's suggest might work, but since this was never intended--and I mean all the way back to the earliest GUI implementation that I can think of--/XView,Motif, etc--to have this behavior so I am not sure how smooth it will look between updates of the title. Keep in mine though, Write logic off of the main thread--meaning you don't create a specific Thread to decide what the new title for the frame will be, you will cause the JFrame to freeze while you are calculating the new title. Remember Swing is not Thread safe--So you may not see what you program...WM
Wintermute
2010-03-22 18:35:08
@Wintermute Its the sort of thing JavaScript did circa 1995.
Tom Hawtin - tackline
2010-03-22 23:57:23
@Tom Ah yes, I remember those dark days? "How do you type cast a Var?..." :D
Wintermute
2010-03-27 13:04:53
You should be using `javax.swing.Timer` not `java.util.TImer`. You might want to use `substring` so as to allow the title to scroll off rather than just getting to the end.
Tom Hawtin - tackline
2010-03-22 14:25:04
+1 for enormity warning. As this code must run on the EDT, a javax.swing.Timer might be preferable. http://java.sun.com/javase/6/docs/api/javax/swing/Timer.html
trashgod
2010-03-22 14:31:05
@Tom, ooh i just understood what you meant, im actually using a Mac, the title appears in the middle of the window, i will need to add spaces once on left then on the right to simulate the marquee.
medopal
2010-03-22 15:03:22
hi! thanks for your answers as well as comments... I really appreciate them. I'll update you about my problem... Sorry for this late reply.. Thanks!
twintwins
2010-03-22 23:48:23