• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Got it working !!!

 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanks to Swami & Nathan with my problem regardint putting the background images in a button, I was able to make it work. All I did was to add an imagePanel directly to the button & add a mouseclicked event to the imagepanel to do the same job as that of the button's mouseclicked event. I used the SCALE_TO_FIT property of the imagepanel to scale the image inside the button & then added it as a component itself to the button.
Thanks again
Meghna
 
Swamy Vatti
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about the other one... multi line button
 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I'm still having some problems with multiline button. I'm using a delimiter "\n" and then wrapping the text to the next line. But, I'm setting the button's/ Imagepanel's layout to Borderlayout & then adding the labels to it. In Boxlayout, the problem is that the text is starting from the left most corner of the button, which does'nt look good since the text needs to be centered, alto' the alignment of the label is set to CENTER.
Any suggestions are welcome !
Thanks
Meghna
 
Swamy Vatti
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did u try using
label.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label.setAlignmentY(JLabel.CENTER_ALIGNMENT);
when the layout is BoxLayout
 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It kinda worked except for the fact that the text is placed at the topmost level of the button, but it is centered now. I'm tryint to work on that right now. Let's hope it works
Thanks
Meghna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic