Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Set the label size  RSS feed

 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is tehre anyway to force the size of the label?

I have set my window size as below:


I have a panel(Flowlayout) which is added inside the scrollpane. Inorder to wrap my components,

I am adding labels into this panel and in order to get a nice look and feel so that each label is one below the other, I am trying set the label size as below(window size)
so that labels are arranged one below the other in every row. But it doesnot seem to work? How do I force to keep a bigger size label than the (getText) size?
Thanks.

[ May 13, 2008: Message edited by: Gopu Akraju ]
[ May 13, 2008: Message edited by: Gopu Akraju ]
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is tied directly to the LayoutManager (or lack thereof) you use, in your case the FlowLayout. This would be a good place to start reading up on how LayoutManagers work and on the details of specific types. I'd recommend reading the tutorial first, but if you need help fast, you could skip ahead and see if this helps you resolve your problem.
[ May 09, 2008: Message edited by: Jelle Klap ]
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks and it is helpful. Let me try.
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I could do it by setting the preferred size for JLabel as below:


Thanks.
[ May 13, 2008: Message edited by: Gopu Akraju ]
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a doubt again. When I use setPreferredSize for JLabel, actionListeners doesnot work on labels. For example I had a mouse listener on JLabel which gets underlined if I click on the label. But after setting the preferredSize for label, it doesn't work. Now the mouse click doesnot underline the label. How do I overcome this problem? Thanks in advance.


[ May 13, 2008: Message edited by: Gopu Akraju ]
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still wondering why mouseListener is not working when I set the size of JLabel through setPreferredSize() method. Please in need to expert advice. Thanks.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to work for me:


[ May 13, 2008: Message edited by: pete stein ]
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is working when I changed the size of JLabel as below:


Initially the size of JLabel was bigger than the panel and hence mouse listener stopped working. When I changed the size of JLabel slightly less than the size of the panel, mouselistner is working now. Thanks.

[ May 26, 2008: Message edited by: Gopu Akraju ]
[ May 26, 2008: Message edited by: Gopu Akraju ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!