0

I'm trying to make a marquee like effect in my program, the text is determined by the content of a file which will result a dynamic lenght/width for JLabel, and the problems are:

  1. I use drag n drop and GroupLayout since it will auto resize the component, but it doesn't allow me to use setBounds nor the setLocation method.

  2. I tried to change it to null layout, yes I can use the setBounds or the setLocation, and now the problem is that the JLabel cannot auto resize its width to fit the text length.

My marquee text would goes from right to the left screen, and will do the run 2 times. Any suggestion here? Thanks :)

mKorbel
  • 109,525
  • 20
  • 134
  • 319
A-SM
  • 882
  • 2
  • 6
  • 18
  • See this answer: http://stackoverflow.com/a/3621417/300257 – Gilbert Le Blanc Jun 25 '13 at 18:01
  • possible duplicate of [Marquee effect in Java Swing](http://stackoverflow.com/questions/3617326/marquee-effect-in-java-swing) – Gilbert Le Blanc Jun 25 '13 at 18:01
  • Damn, I didn't think there was a topic with that title, I was focused on 'set location on GroupLayout' and such -,- – A-SM Jun 25 '13 at 18:24
  • Umm, @GilbertLeBlanc, I'm not asking how to do the marquee by the way, but how to setLocation in GroupLayout or auto resize in null layout. – A-SM Jun 25 '13 at 18:35
  • The answer I pointed you to had a JFrame and a default BorderLayout. – Gilbert Le Blanc Jun 25 '13 at 18:41
  • 1
    Don't use an IDE to design your form. Then you are free to use any Layout Manager to accomplish your task. Usually a marquee is set to a fixed size independent of the text size. Then text just scrolls in the space available. This way you don't limit the text to the size of the component and you can have longer methods. – camickr Jun 25 '13 at 18:47

0 Answers0